Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use Rust 1.65.0 #16688

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ jobs:
# to complete.
sudo apt-get remove --purge -y man-db

# Install clang-14, lld-14, and debootstrap.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main" |
sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-14.list
# Install clang-15, lld-15, and debootstrap.
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" |
sudo dd of=/etc/apt/sources.list.d/llvm-toolchain-focal-15.list
curl https://apt.llvm.org/llvm-snapshot.gpg.key |
gpg --dearmor |
sudo dd of=/etc/apt/trusted.gpg.d/llvm-snapshot.gpg
sudo apt-get update
sudo apt-get install --no-install-recommends debootstrap \
clang-14 lld-14
clang-15 lld-15

# Create ubuntu-16.04 sysroot environment, which is used to avoid
# depending on a very recent version of glibc.
Expand All @@ -190,8 +190,8 @@ jobs:
CARGO_PROFILE_RELEASE_LTO=false
RUSTFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C linker=clang-15
-C link-arg=-fuse-ld=lld-15
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
Expand All @@ -200,15 +200,15 @@ jobs:
__1
RUSTDOCFLAGS<<__1
-C linker-plugin-lto=true
-C linker=clang-14
-C link-arg=-fuse-ld=lld-14
-C linker=clang-15
-C link-arg=-fuse-ld=lld-15
-C link-arg=--sysroot=/sysroot
-C link-arg=-Wl,--allow-shlib-undefined
-C link-arg=-Wl,--thinlto-cache-dir=$(pwd)/target/release/lto-cache
-C link-arg=-Wl,--thinlto-cache-policy,cache_size_bytes=700m
${{ env.RUSTFLAGS }}
__1
CC=clang-14
CC=clang-15
CFLAGS=-flto=thin --sysroot=/sysroot
__0

Expand Down
12 changes: 6 additions & 6 deletions cli/args/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ fn clap_root(version: &str) -> Command {
.help("Set log level")
.hide(true)
.takes_value(true)
.possible_values(&["debug", "info"])
.possible_values(["debug", "info"])
.global(true),
)
.arg(
Expand Down Expand Up @@ -811,7 +811,7 @@ fn compile_subcommand<'a>() -> Command<'a> {
.long("target")
.help("Target OS architecture")
.takes_value(true)
.possible_values(&[
.possible_values([
"x86_64-unknown-linux-gnu",
"x86_64-pc-windows-msvc",
"x86_64-apple-darwin",
Expand Down Expand Up @@ -848,7 +848,7 @@ fn completions_subcommand<'a>() -> Command<'a> {
.disable_help_subcommand(true)
.arg(
Arg::new("shell")
.possible_values(&["bash", "fish", "powershell", "zsh", "fig"])
.possible_values(["bash", "fish", "powershell", "zsh", "fig"])
.required(true),
)
.about("Generate shell completions")
Expand Down Expand Up @@ -1049,7 +1049,7 @@ This command has implicit access to all permissions (--allow-all).",
.help("Set standard input (stdin) content type")
.takes_value(true)
.default_value("js")
.possible_values(&["ts", "tsx", "js", "jsx"]),
.possible_values(["ts", "tsx", "js", "jsx"]),
)
.arg(
Arg::new("print")
Expand Down Expand Up @@ -1106,7 +1106,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
.help("Set standard input (stdin) content type")
.takes_value(true)
.default_value("ts")
.possible_values(&["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]),
.possible_values(["ts", "tsx", "js", "jsx", "md", "json", "jsonc"]),
)
.arg(
Arg::new("ignore")
Expand Down Expand Up @@ -1165,7 +1165,7 @@ Ignore formatting a file by adding an ignore comment at the top of the file:
Arg::new("options-prose-wrap")
.long("options-prose-wrap")
.takes_value(true)
.possible_values(&["always", "never", "preserve"])
.possible_values(["always", "never", "preserve"])
.help("Define how prose should be wrapped. Defaults to always."),
)
}
Expand Down
4 changes: 2 additions & 2 deletions cli/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, i64>> {

for (name, args, return_code) in EXEC_TIME_BENCHMARKS {
let proc = Command::new("time")
.args(&["-v", deno_exe.to_str().unwrap()])
.args(["-v", deno_exe.to_str().unwrap()])
.args(args.iter())
.stdout(Stdio::null())
.stderr(Stdio::piped())
Expand Down Expand Up @@ -501,7 +501,7 @@ async fn main() -> Result<()> {
let mut file = secure_tempfile::NamedTempFile::new()?;

let exit_status = Command::new("strace")
.args(&[
.args([
"-c",
"-f",
"-o",
Expand Down
4 changes: 2 additions & 2 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn create_snapshot(
}

let snapshot = js_runtime.snapshot();
let snapshot_slice: &[u8] = &*snapshot;
let snapshot_slice: &[u8] = &snapshot;
println!("Snapshot size: {}", snapshot_slice.len());

let compressed_snapshot_with_size = {
Expand All @@ -64,7 +64,7 @@ fn create_snapshot(
compressed_snapshot_with_size.len()
);

std::fs::write(&snapshot_path, compressed_snapshot_with_size).unwrap();
std::fs::write(snapshot_path, compressed_snapshot_with_size).unwrap();
println!("Snapshot written to: {} ", snapshot_path.display());
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cache/disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl DiskCache {
if path.is_dir() {
return Ok(());
}
fs::create_dir_all(&path).map_err(|e| {
fs::create_dir_all(path).map_err(|e| {
io::Error::new(e.kind(), format!(
"Could not create TypeScript compiler cache location: {:?}\nCheck the permission of the directory.",
path
Expand Down
10 changes: 5 additions & 5 deletions cli/fs_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ pub async fn remove_dir_all_if_exists(path: &Path) -> std::io::Result<()> {
///
/// Note: Does not handle symlinks.
pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
std::fs::create_dir_all(&to)
std::fs::create_dir_all(to)
.with_context(|| format!("Creating {}", to.display()))?;
let read_dir = std::fs::read_dir(&from)
let read_dir = std::fs::read_dir(from)
.with_context(|| format!("Reading {}", from.display()))?;

for entry in read_dir {
Expand All @@ -362,9 +362,9 @@ pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
///
/// Note: Does not handle symlinks.
pub fn hard_link_dir_recursive(from: &Path, to: &Path) -> Result<(), AnyError> {
std::fs::create_dir_all(&to)
std::fs::create_dir_all(to)
.with_context(|| format!("Creating {}", to.display()))?;
let read_dir = std::fs::read_dir(&from)
let read_dir = std::fs::read_dir(from)
.with_context(|| format!("Reading {}", from.display()))?;

for entry in read_dir {
Expand Down Expand Up @@ -451,7 +451,7 @@ pub fn symlink_dir(oldpath: &Path, newpath: &Path) -> Result<(), AnyError> {
#[cfg(unix)]
{
use std::os::unix::fs::symlink;
symlink(&oldpath, &newpath).map_err(err_mapper)?;
symlink(oldpath, newpath).map_err(err_mapper)?;
}
#[cfg(not(unix))]
{
Expand Down
2 changes: 1 addition & 1 deletion cli/http_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl HttpCache {
if path.is_dir() {
return Ok(());
}
fs::create_dir_all(&path).map_err(|e| {
fs::create_dir_all(path).map_err(|e| {
io::Error::new(
e.kind(),
format!(
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ fn get_workspace_completions(
specifier_strings
.into_iter()
.filter_map(|label| {
if label.starts_with(&current) {
if label.starts_with(current) {
let detail = Some(
if label.starts_with("http:") || label.starts_with("https:") {
"(remote)".to_string()
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/path_to_regex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ mod tests {
assert!(result.is_ok(), "Could not parse path: \"{}\"", path);
let (re, _) = result.unwrap();
for (fixture, expected) in fixtures {
let result = re.find(*fixture);
let result = re.find(fixture);
assert!(
result.is_ok(),
"Find failure for path \"{}\" and fixture \"{}\"",
Expand Down
4 changes: 2 additions & 2 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ async fn test_command(
test_flags: TestFlags,
) -> Result<i32, AnyError> {
if let Some(ref coverage_dir) = flags.coverage_dir {
std::fs::create_dir_all(&coverage_dir)?;
std::fs::create_dir_all(coverage_dir)?;
env::set_var(
"DENO_UNSTABLE_COVERAGE_DIR",
PathBuf::from(coverage_dir).canonicalize()?,
Expand Down Expand Up @@ -994,7 +994,7 @@ pub fn main() {
Err(err) => unwrap_or_exit(Err(AnyError::from(err))),
};
if !flags.v8_flags.is_empty() {
init_v8_flags(&*flags.v8_flags);
init_v8_flags(&flags.v8_flags);
}

logger::init(flags.log_level);
Expand Down
2 changes: 1 addition & 1 deletion cli/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl CliModuleLoader {
let file_path = specifier.to_file_path().unwrap();
let code = std::fs::read_to_string(&file_path).with_context(|| {
let mut msg = "Unable to load ".to_string();
msg.push_str(&*file_path.to_string_lossy());
msg.push_str(&file_path.to_string_lossy());
if let Some(referrer) = &maybe_referrer {
msg.push_str(" imported from ");
msg.push_str(referrer.as_str());
Expand Down
4 changes: 2 additions & 2 deletions cli/npm/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn with_folder_sync_lock(
match inner(output_folder, action) {
Ok(()) => Ok(()),
Err(err) => {
if let Err(remove_err) = fs::remove_dir_all(&output_folder) {
if let Err(remove_err) = fs::remove_dir_all(output_folder) {
if remove_err.kind() != std::io::ErrorKind::NotFound {
bail!(
concat!(
Expand Down Expand Up @@ -156,7 +156,7 @@ impl ReadonlyNpmCache {
root_dir: &Path,
) -> Result<PathBuf, AnyError> {
if !root_dir.exists() {
std::fs::create_dir_all(&root_dir)
std::fs::create_dir_all(root_dir)
.with_context(|| format!("Error creating {}", root_dir.display()))?;
}
Ok(crate::fs_util::canonicalize_path(root_dir)?)
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl RealNpmRegistryApiInner {
) -> Result<(), AnyError> {
let file_cache_path = self.get_package_file_cache_path(name);
let file_text = serde_json::to_string(&package_info)?;
std::fs::create_dir_all(&file_cache_path.parent().unwrap())?;
std::fs::create_dir_all(file_cache_path.parent().unwrap())?;
fs_util::atomic_write_file(&file_cache_path, file_text, CACHE_PERM)?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/resolution/specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn resolve_npm_package_reqs(graph: &ModuleGraph) -> Vec<NpmPackageReq> {
for specifier in &specifiers {
if let Ok(npm_ref) = NpmPackageReference::from_specifier(specifier) {
leaf.reqs.insert(npm_ref.req);
} else if !specifier.as_str().starts_with(&parent_specifier.as_str()) {
} else if !specifier.as_str().starts_with(parent_specifier.as_str()) {
leaf
.dependencies
.insert(get_folder_path_specifier(specifier));
Expand Down
2 changes: 1 addition & 1 deletion cli/npm/resolvers/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn ensure_registry_read_permission(
path: &Path,
) -> Result<(), AnyError> {
// allow reading if it's in the node_modules
if path.starts_with(&registry_path)
if path.starts_with(registry_path)
&& path
.components()
.all(|c| !matches!(c, std::path::Component::ParentDir))
Expand Down
4 changes: 2 additions & 2 deletions cli/npm/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ fn extract_tarball(data: &[u8], output_folder: &Path) -> Result<(), AnyError> {
absolute_path.parent().unwrap()
};
if created_dirs.insert(dir_path.to_path_buf()) {
fs::create_dir_all(&dir_path)?;
let canonicalized_dir = fs::canonicalize(&dir_path)?;
fs::create_dir_all(dir_path)?;
let canonicalized_dir = fs::canonicalize(dir_path)?;
if !canonicalized_dir.starts_with(&output_folder) {
bail!(
"Extracted directory '{}' of npm tarball was not in output directory.",
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/integration/info_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn info_with_compiled_source() {
.env("DENO_DIR", t.path())
.current_dir(util::testdata_path())
.arg("cache")
.arg(&module_path)
.arg(module_path)
.spawn()
.unwrap();
let status = deno.wait().unwrap();
Expand All @@ -26,7 +26,7 @@ fn info_with_compiled_source() {
.env("NO_COLOR", "1")
.current_dir(util::testdata_path())
.arg("info")
.arg(&module_path)
.arg(module_path)
.output()
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6077,7 +6077,7 @@ Deno.test({
}
});
"#;
fs::write(&module_path, &contents).unwrap();
fs::write(&module_path, contents).unwrap();
fs::write(temp_dir.path().join("./deno.jsonc"), r#"{}"#).unwrap();

params.root_uri = Some(root_specifier);
Expand Down
3 changes: 1 addition & 2 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1703,8 +1703,7 @@ fn exec_path() {
.unwrap();
assert!(output.status.success());
let stdout_str = std::str::from_utf8(&output.stdout).unwrap().trim();
let actual =
std::fs::canonicalize(&std::path::Path::new(stdout_str)).unwrap();
let actual = std::fs::canonicalize(std::path::Path::new(stdout_str)).unwrap();
let expected = std::fs::canonicalize(util::deno_exe_path()).unwrap();
assert_eq!(expected, actual);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/upgrade_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn upgrade_with_out_in_tmpdir() {
.arg("--version")
.arg("1.11.5")
.arg("--output")
.arg(&new_exe_path.to_str().unwrap())
.arg(new_exe_path.to_str().unwrap())
.spawn()
.unwrap()
.wait()
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/integration/vendor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn existing_import_map_no_remote() {
let import_map_filename = "imports2.json";
let import_map_text =
r#"{ "imports": { "http://localhost:4545/vendor/": "./logger/" } }"#;
t.write(import_map_filename, &import_map_text);
t.write(import_map_filename, import_map_text);
t.create_dir_all("logger");
t.write("logger/logger.ts", "export class Logger {}");

Expand Down
8 changes: 4 additions & 4 deletions cli/tests/integration/watcher_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ fn lint_all_files_on_each_change_test() {
let mut child = util::deno_cmd()
.current_dir(util::testdata_path())
.arg("lint")
.arg(&t.path())
.arg(t.path())
.arg("--watch")
.arg("--unstable")
.stdout(std::process::Stdio::piped())
Expand Down Expand Up @@ -349,7 +349,7 @@ fn fmt_check_all_files_on_each_change_test() {
let mut child = util::deno_cmd()
.current_dir(&fmt_testdata_path)
.arg("fmt")
.arg(&t.path())
.arg(t.path())
.arg("--watch")
.arg("--check")
.arg("--unstable")
Expand Down Expand Up @@ -832,7 +832,7 @@ fn test_watch() {
.arg("--watch")
.arg("--unstable")
.arg("--no-check")
.arg(&t.path())
.arg(t.path())
.env("NO_COLOR", "1")
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
Expand Down Expand Up @@ -973,7 +973,7 @@ fn test_watch_doc() {
.arg("--watch")
.arg("--doc")
.arg("--unstable")
.arg(&t.path())
.arg(t.path())
.env("NO_COLOR", "1")
.stdout(std::process::Stdio::piped())
.stderr(std::process::Stdio::piped())
Expand Down
2 changes: 1 addition & 1 deletion cli/tools/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl BenchReporter for ConsoleReporter {
println!();
}

if None == self.group || group != self.group.as_ref().unwrap() {
if self.group.is_none() || group != self.group.as_ref().unwrap() {
self.report_group_summary();
}

Expand Down
Loading