Skip to content

Commit

Permalink
chore: update to Rust 1.66.0 (denoland#17078)
Browse files Browse the repository at this point in the history
  • Loading branch information
linbingquan committed Dec 17, 2022
1 parent f2c9cc5 commit f46df3e
Show file tree
Hide file tree
Showing 37 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion cli/args/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl ConfigFile {

pub fn from_specifier(specifier: &ModuleSpecifier) -> Result<Self, AnyError> {
let config_path = specifier_to_file_path(specifier)?;
let config_text = match std::fs::read_to_string(&config_path) {
let config_text = match std::fs::read_to_string(config_path) {
Ok(text) => text,
Err(err) => bail!(
"Error reading config file {}: {}",
Expand Down
4 changes: 2 additions & 2 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ pub fn get_root_cert_store(
} else {
PathBuf::from(ca_file)
};
let certfile = std::fs::File::open(&ca_file)?;
let certfile = std::fs::File::open(ca_file)?;
let mut reader = BufReader::new(certfile);

match rustls_pemfile::certs(&mut reader) {
Expand Down Expand Up @@ -720,7 +720,7 @@ mod test {
let import_map_path =
std::env::current_dir().unwrap().join("import-map.json");
let expected_specifier =
ModuleSpecifier::from_file_path(&import_map_path).unwrap();
ModuleSpecifier::from_file_path(import_map_path).unwrap();
assert!(actual.is_ok());
let actual = actual.unwrap();
assert_eq!(actual, Some(expected_specifier));
Expand Down
2 changes: 1 addition & 1 deletion cli/bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ async fn main() -> Result<()> {

let target_dir = test_util::target_dir();
let deno_exe = test_util::deno_exe_path();
env::set_current_dir(&test_util::root_path())?;
env::set_current_dir(test_util::root_path())?;

let mut new_data = BenchResult {
created_at: chrono::Utc::now()
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 @@ -136,7 +136,7 @@ impl DiskCache {

pub fn get(&self, filename: &Path) -> std::io::Result<Vec<u8>> {
let path = self.location.join(filename);
fs::read(&path)
fs::read(path)
}

pub fn set(&self, filename: &Path, data: &[u8]) -> std::io::Result<()> {
Expand Down
6 changes: 3 additions & 3 deletions cli/lsp/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ mod tests {
let file_c = dir_a.join("c.ts");
std::fs::write(&file_c, b"").expect("could not create");
let file_d = dir_b.join("d.ts");
std::fs::write(&file_d, b"").expect("could not create");
std::fs::write(file_d, b"").expect("could not create");
let file_e = dir_a.join("e.txt");
std::fs::write(&file_e, b"").expect("could not create");
std::fs::write(file_e, b"").expect("could not create");
let file_f = dir_a.join("f.mjs");
std::fs::write(&file_f, b"").expect("could not create");
std::fs::write(file_f, b"").expect("could not create");
let specifier =
ModuleSpecifier::from_file_path(file_c).expect("could not create");
let actual = get_local_completions(
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ fn lsp_deno_graph_analyze(
use deno_graph::ModuleParser;

let analyzer = deno_graph::CapturingModuleAnalyzer::new(
Some(Box::new(LspModuleParser::default())),
Some(Box::<LspModuleParser>::default()),
None,
);
let parsed_source_result = analyzer.parse_module(
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/registries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ impl ModuleRegistry {
None
} else {
Some(lsp::CompletionList {
items: completions.into_iter().map(|(_, i)| i).collect(),
items: completions.into_values().collect(),
is_incomplete,
})
};
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ impl CompletionEntryDetails {
let detail = if original_item.detail.is_some() {
original_item.detail.clone()
} else if !self.display_parts.is_empty() {
Some(replace_links(&display_parts_to_string(
Some(replace_links(display_parts_to_string(
&self.display_parts,
language_server,
)))
Expand Down
6 changes: 3 additions & 3 deletions cli/napi/js_native_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ fn napi_create_string_latin1(
.unwrap()
.as_bytes()
} else {
std::slice::from_raw_parts(string, length as usize)
std::slice::from_raw_parts(string, length)
};
match v8::String::new_from_one_byte(
&mut env.scope(),
Expand Down Expand Up @@ -626,7 +626,7 @@ fn napi_create_string_utf8(
.to_str()
.unwrap()
} else {
let string = std::slice::from_raw_parts(string, length as usize);
let string = std::slice::from_raw_parts(string, length);
std::str::from_utf8(string).unwrap()
};
let v8str = v8::String::new(&mut env.scope(), string).unwrap();
Expand Down Expand Up @@ -1070,7 +1070,7 @@ fn napi_call_function(
.map_err(|_| Error::FunctionExpected)?;

let argv: &[v8::Local<v8::Value>] =
transmute(std::slice::from_raw_parts(argv, argc as usize));
transmute(std::slice::from_raw_parts(argv, argc));
let ret = func.call(&mut env.scope(), recv, argv);
if !result.is_null() {
*result = transmute::<Option<v8::Local<v8::Value>>, napi_value>(ret);
Expand Down
4 changes: 2 additions & 2 deletions cli/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ fn finalize_resolution(
p_str.to_string()
};

let (is_dir, is_file) = if let Ok(stats) = std::fs::metadata(&p) {
let (is_dir, is_file) = if let Ok(stats) = std::fs::metadata(p) {
(stats.is_dir(), stats.is_file())
} else {
(false, false)
Expand Down Expand Up @@ -958,7 +958,7 @@ pub fn translate_cjs_to_esm(
npm_resolver,
)?;
let reexport_specifier =
ModuleSpecifier::from_file_path(&resolved_reexport).unwrap();
ModuleSpecifier::from_file_path(resolved_reexport).unwrap();
// Second, read the source code from disk
let reexport_file = file_fetcher
.get_source(&reexport_specifier)
Expand Down
8 changes: 4 additions & 4 deletions cli/npm/resolvers/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ async fn sync_resolution_with_fs(
for package in &package_partitions.copy_packages {
let package_cache_folder_id = package.get_package_cache_folder_id();
let destination_path = deno_local_registry_dir
.join(&get_package_folder_id_folder_name(&package_cache_folder_id));
.join(get_package_folder_id_folder_name(&package_cache_folder_id));
let initialized_file = destination_path.join(".initialized");
if !initialized_file.exists() {
let sub_node_modules = destination_path.join("node_modules");
Expand All @@ -352,7 +352,7 @@ async fn sync_resolution_with_fs(
})?;
let source_path = join_package_name(
&deno_local_registry_dir
.join(&get_package_folder_id_folder_name(
.join(get_package_folder_id_folder_name(
&package_cache_folder_id.with_no_count(),
))
.join("node_modules"),
Expand All @@ -372,7 +372,7 @@ async fn sync_resolution_with_fs(
// node_modules/.deno/<dep_id>/node_modules/<dep_package_name>
for package in &all_packages {
let sub_node_modules = deno_local_registry_dir
.join(&get_package_folder_id_folder_name(
.join(get_package_folder_id_folder_name(
&package.get_package_cache_folder_id(),
))
.join("node_modules");
Expand Down Expand Up @@ -419,7 +419,7 @@ async fn sync_resolution_with_fs(
let package = snapshot.package_from_id(&package_id).unwrap();
let local_registry_package_path = join_package_name(
&deno_local_registry_dir
.join(&get_package_folder_id_folder_name(
.join(get_package_folder_id_folder_name(
&package.get_package_cache_folder_id(),
))
.join("node_modules"),
Expand Down
4 changes: 2 additions & 2 deletions cli/npm/resolvers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl RequireNpmResolver for NpmPackageResolver {

fn in_npm_package(&self, path: &Path) -> bool {
let specifier =
match ModuleSpecifier::from_file_path(&path.to_path_buf().clean()) {
match ModuleSpecifier::from_file_path(path.to_path_buf().clean()) {
Ok(p) => p,
Err(_) => return false,
};
Expand All @@ -370,7 +370,7 @@ impl RequireNpmResolver for NpmPackageResolver {
}

fn path_to_specifier(path: &Path) -> Result<ModuleSpecifier, AnyError> {
match ModuleSpecifier::from_file_path(&path.to_path_buf().clean()) {
match ModuleSpecifier::from_file_path(path.to_path_buf().clean()) {
Ok(specifier) => Ok(specifier),
Err(()) => bail!("Could not convert '{}' to url.", path.display()),
}
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/coverage_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod coverage {
// Write the inital mod.ts file
std::fs::copy(mod_before_path, &mod_temp_path).unwrap();
// And the test file
std::fs::copy(mod_test_path, &mod_test_temp_path).unwrap();
std::fs::copy(mod_test_path, mod_test_temp_path).unwrap();

// Generate coverage
let status = util::deno_cmd_with_deno_dir(&deno_dir)
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/fmt_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ mod fmt {
testdata_fmt_dir.join("badly_formatted.mjs");
let badly_formatted_js = t.path().join("badly_formatted.js");
let badly_formatted_js_str = badly_formatted_js.to_str().unwrap();
std::fs::copy(&badly_formatted_original_js, &badly_formatted_js).unwrap();
std::fs::copy(badly_formatted_original_js, &badly_formatted_js).unwrap();

let fixed_md = testdata_fmt_dir.join("badly_formatted_fixed.md");
let badly_formatted_original_md =
testdata_fmt_dir.join("badly_formatted.md");
let badly_formatted_md = t.path().join("badly_formatted.md");
let badly_formatted_md_str = badly_formatted_md.to_str().unwrap();
std::fs::copy(&badly_formatted_original_md, &badly_formatted_md).unwrap();
std::fs::copy(badly_formatted_original_md, &badly_formatted_md).unwrap();

let fixed_json = testdata_fmt_dir.join("badly_formatted_fixed.json");
let badly_formatted_original_json =
testdata_fmt_dir.join("badly_formatted.json");
let badly_formatted_json = t.path().join("badly_formatted.json");
let badly_formatted_json_str = badly_formatted_json.to_str().unwrap();
std::fs::copy(&badly_formatted_original_json, &badly_formatted_json)
std::fs::copy(badly_formatted_original_json, &badly_formatted_json)
.unwrap();
// First, check formatting by ignoring the badly formatted file.
let status = util::deno_cmd()
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2505,7 +2505,7 @@ mod run {
.unwrap();
assert!(status.success());
std::fs::write(&mod1_path, "export { foo } from \"./mod2.ts\";").unwrap();
std::fs::write(&mod2_path, "(").unwrap();
std::fs::write(mod2_path, "(").unwrap();
let status = deno_cmd
.current_dir(util::testdata_path())
.arg("run")
Expand All @@ -2528,7 +2528,7 @@ mod run {
let mut deno_cmd = util::deno_cmd();
// With a fresh `DENO_DIR`, run a module with a dependency and a type error.
std::fs::write(&mod1_path, "import './mod2.ts'; Deno.exit('0');").unwrap();
std::fs::write(&mod2_path, "console.log('Hello, world!');").unwrap();
std::fs::write(mod2_path, "console.log('Hello, world!');").unwrap();
let status = deno_cmd
.current_dir(util::testdata_path())
.arg("run")
Expand Down Expand Up @@ -2969,7 +2969,7 @@ mod run {
assert!(output.status.success());

let prg = util::deno_exe_path();
let output = Command::new(&prg)
let output = Command::new(prg)
.env("DENO_DIR", deno_dir.path())
.env("HTTP_PROXY", "http:https://nil")
.env("NO_COLOR", "1")
Expand Down
24 changes: 12 additions & 12 deletions cli/tests/watcher_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod watcher {
util::testdata_path().join("lint/watch/badly_linted_fixed2.js.out");
let badly_linted = t.path().join("badly_linted.js");

std::fs::copy(&badly_linted_original, &badly_linted).unwrap();
std::fs::copy(badly_linted_original, &badly_linted).unwrap();

let mut child = util::deno_cmd()
.current_dir(util::testdata_path())
Expand All @@ -125,15 +125,15 @@ mod watcher {
assert_eq!(output, expected);

// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed1, &badly_linted).unwrap();
std::fs::copy(badly_linted_fixed1, &badly_linted).unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));

output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
assert_eq!(output, expected);

// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed2, &badly_linted).unwrap();
std::fs::copy(badly_linted_fixed2, &badly_linted).unwrap();

output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed2_output).unwrap();
Expand Down Expand Up @@ -163,7 +163,7 @@ mod watcher {
util::testdata_path().join("lint/watch/badly_linted_fixed2.js.out");
let badly_linted = t.path().join("badly_linted.js");

std::fs::copy(&badly_linted_original, &badly_linted).unwrap();
std::fs::copy(badly_linted_original, &badly_linted).unwrap();

let mut child = util::deno_cmd()
.current_dir(t.path())
Expand All @@ -183,14 +183,14 @@ mod watcher {
assert_eq!(output, expected);

// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed1, &badly_linted).unwrap();
std::fs::copy(badly_linted_fixed1, &badly_linted).unwrap();

output = read_all_lints(&mut stderr_lines);
let expected = std::fs::read_to_string(badly_linted_fixed1_output).unwrap();
assert_eq!(output, expected);

// Change content of the file again to be badly-linted1
std::fs::copy(&badly_linted_fixed2, &badly_linted).unwrap();
std::fs::copy(badly_linted_fixed2, &badly_linted).unwrap();
std::thread::sleep(std::time::Duration::from_secs(1));

output = read_all_lints(&mut stderr_lines);
Expand All @@ -216,8 +216,8 @@ mod watcher {

let badly_linted_1 = t.path().join("badly_linted_1.js");
let badly_linted_2 = t.path().join("badly_linted_2.js");
std::fs::copy(&badly_linted_fixed0, &badly_linted_1).unwrap();
std::fs::copy(&badly_linted_fixed1, &badly_linted_2).unwrap();
std::fs::copy(badly_linted_fixed0, badly_linted_1).unwrap();
std::fs::copy(badly_linted_fixed1, &badly_linted_2).unwrap();

let mut child = util::deno_cmd()
.current_dir(util::testdata_path())
Expand All @@ -236,7 +236,7 @@ mod watcher {
"Checked 2 files"
);

std::fs::copy(&badly_linted_fixed2, &badly_linted_2).unwrap();
std::fs::copy(badly_linted_fixed2, badly_linted_2).unwrap();

assert_contains!(
read_line("Checked", &mut stderr_lines),
Expand Down Expand Up @@ -356,7 +356,7 @@ mod watcher {
let badly_formatted_1 = t.path().join("badly_formatted_1.js");
let badly_formatted_2 = t.path().join("badly_formatted_2.js");
std::fs::copy(&badly_formatted_original, &badly_formatted_1).unwrap();
std::fs::copy(&badly_formatted_original, &badly_formatted_2).unwrap();
std::fs::copy(&badly_formatted_original, badly_formatted_2).unwrap();

let mut child = util::deno_cmd()
.current_dir(&fmt_testdata_path)
Expand Down Expand Up @@ -868,7 +868,7 @@ mod watcher {
)
.unwrap();
write(
&bar_test,
bar_test,
"import bar from './bar.js'; Deno.test('bar', bar);",
)
.unwrap();
Expand Down Expand Up @@ -1102,7 +1102,7 @@ mod watcher {
.unwrap();
let file_to_watch2 = t.path().join("imported.js");
write(
&file_to_watch2,
file_to_watch2,
r#"
import "./imported2.js";
console.log("I'm dynamically imported and I cause restarts!");
Expand Down
4 changes: 2 additions & 2 deletions cli/tools/coverage/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ pub fn merge_scripts(
}

let functions: Vec<FunctionCoverage> = range_to_funcs
.into_iter()
.map(|(_, funcs)| merge_functions(funcs).unwrap())
.into_values()
.map(|funcs| merge_functions(funcs).unwrap())
.collect();

Some(ScriptCoverage {
Expand Down
10 changes: 4 additions & 6 deletions cli/tools/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn print_cache_info(

if let Some(location) = &location {
origin_dir =
origin_dir.join(&checksum::gen(&[location.to_string().as_bytes()]));
origin_dir.join(checksum::gen(&[location.to_string().as_bytes()]));
}

let local_storage_dir = origin_dir.join("local_storage");
Expand Down Expand Up @@ -526,11 +526,9 @@ impl<'a> GraphDisplayContext<'a> {
Specifier(_) => specifier_str,
};
let maybe_size = match &package_or_specifier {
Package(package) => self
.npm_info
.package_sizes
.get(&package.id)
.map(|s| *s as u64),
Package(package) => {
self.npm_info.package_sizes.get(&package.id).copied()
}
Specifier(_) => module
.maybe_source
.as_ref()
Expand Down
Loading

0 comments on commit f46df3e

Please sign in to comment.