diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2023-01-27 10:43:16 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-27 10:43:16 -0500 |
| commit | f5840bdcd360ec0bac2501f333e58e25742b1537 (patch) | |
| tree | 7eb0818d2cafa0f6824e81b6ed2cfb609830971e /cli/tools | |
| parent | 1a1faff2f67613ed0b89e1a34e6c3fd02ca6fd83 (diff) | |
chore: upgrade to Rust 1.67 (#17548)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tools')
| -rw-r--r-- | cli/tools/coverage/mod.rs | 16 | ||||
| -rw-r--r-- | cli/tools/doc.rs | 2 | ||||
| -rw-r--r-- | cli/tools/fmt.rs | 13 | ||||
| -rw-r--r-- | cli/tools/info.rs | 5 | ||||
| -rw-r--r-- | cli/tools/init/mod.rs | 2 | ||||
| -rw-r--r-- | cli/tools/installer.rs | 28 | ||||
| -rw-r--r-- | cli/tools/lint.rs | 12 | ||||
| -rw-r--r-- | cli/tools/repl/editor.rs | 5 | ||||
| -rw-r--r-- | cli/tools/repl/mod.rs | 13 | ||||
| -rw-r--r-- | cli/tools/repl/session.rs | 5 | ||||
| -rw-r--r-- | cli/tools/standalone.rs | 6 | ||||
| -rw-r--r-- | cli/tools/task.rs | 6 | ||||
| -rw-r--r-- | cli/tools/test.rs | 8 | ||||
| -rw-r--r-- | cli/tools/upgrade.rs | 4 | ||||
| -rw-r--r-- | cli/tools/vendor/build.rs | 10 | ||||
| -rw-r--r-- | cli/tools/vendor/import_map.rs | 2 | ||||
| -rw-r--r-- | cli/tools/vendor/mappings.rs | 6 | ||||
| -rw-r--r-- | cli/tools/vendor/specifiers.rs | 2 |
18 files changed, 61 insertions, 84 deletions
diff --git a/cli/tools/coverage/mod.rs b/cli/tools/coverage/mod.rs index 056ed4ab4..4b2bcd49d 100644 --- a/cli/tools/coverage/mod.rs +++ b/cli/tools/coverage/mod.rs @@ -413,7 +413,7 @@ impl CoverageReporter for LcovCoverageReporter { .ok() .and_then(|p| p.to_str().map(|p| p.to_string())) .unwrap_or_else(|| coverage_report.url.to_string()); - writeln!(out_writer, "SF:{}", file_path)?; + writeln!(out_writer, "SF:{file_path}")?; for function in &coverage_report.named_functions { writeln!( @@ -433,13 +433,13 @@ impl CoverageReporter for LcovCoverageReporter { } let functions_found = coverage_report.named_functions.len(); - writeln!(out_writer, "FNF:{}", functions_found)?; + writeln!(out_writer, "FNF:{functions_found}")?; let functions_hit = coverage_report .named_functions .iter() .filter(|f| f.execution_count > 0) .count(); - writeln!(out_writer, "FNH:{}", functions_hit)?; + writeln!(out_writer, "FNH:{functions_hit}")?; for branch in &coverage_report.branches { let taken = if let Some(taken) = &branch.taken { @@ -459,10 +459,10 @@ impl CoverageReporter for LcovCoverageReporter { } let branches_found = coverage_report.branches.len(); - writeln!(out_writer, "BRF:{}", branches_found)?; + writeln!(out_writer, "BRF:{branches_found}")?; let branches_hit = coverage_report.branches.iter().filter(|b| b.is_hit).count(); - writeln!(out_writer, "BRH:{}", branches_hit)?; + writeln!(out_writer, "BRH:{branches_hit}")?; for (index, count) in &coverage_report.found_lines { writeln!(out_writer, "DA:{},{}", index + 1, count)?; } @@ -472,10 +472,10 @@ impl CoverageReporter for LcovCoverageReporter { .iter() .filter(|(_, count)| *count != 0) .count(); - writeln!(out_writer, "LH:{}", lines_hit)?; + writeln!(out_writer, "LH:{lines_hit}")?; let lines_found = coverage_report.found_lines.len(); - writeln!(out_writer, "LF:{}", lines_found)?; + writeln!(out_writer, "LF:{lines_found}")?; writeln!(out_writer, "end_of_record")?; Ok(()) @@ -664,7 +664,7 @@ pub async fn cover_files( ps.file_fetcher .fetch_cached(&module_specifier, 10) .with_context(|| { - format!("Failed to fetch \"{}\" from cache.", module_specifier) + format!("Failed to fetch \"{module_specifier}\" from cache.") })? }; let file = maybe_file.ok_or_else(|| { diff --git a/cli/tools/doc.rs b/cli/tools/doc.rs index 163d3ffcd..e27e49570 100644 --- a/cli/tools/doc.rs +++ b/cli/tools/doc.rs @@ -69,7 +69,7 @@ pub async fn print_docs( local: PathBuf::from("./$deno$doc.ts"), maybe_types: None, media_type: MediaType::TypeScript, - source: format!("export * from \"{}\";", module_specifier).into(), + source: format!("export * from \"{module_specifier}\";").into(), specifier: root_specifier.clone(), maybe_headers: None, }; diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 441d4fe08..a2d9a3027 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -183,7 +183,7 @@ fn format_markdown( dprint_plugin_json::format_text(text, &json_config) } else { let fake_filename = - PathBuf::from(format!("deno_fmt_stdin.{}", extension)); + PathBuf::from(format!("deno_fmt_stdin.{extension}")); let mut codeblock_config = get_resolved_typescript_config(fmt_options); codeblock_config.line_width = line_width; @@ -287,13 +287,13 @@ async fn check_source_files( warn!("Error checking: {}", file_path.to_string_lossy()); warn!( "{}", - format!("{}", e) + format!("{e}") .split('\n') .map(|l| { if l.trim().is_empty() { String::new() } else { - format!(" {}", l) + format!(" {l}") } }) .collect::<Vec<_>>() @@ -317,8 +317,7 @@ async fn check_source_files( } else { let not_formatted_files_str = files_str(not_formatted_files_count); Err(generic_error(format!( - "Found {} not formatted {} in {}", - not_formatted_files_count, not_formatted_files_str, checked_files_str, + "Found {not_formatted_files_count} not formatted {not_formatted_files_str} in {checked_files_str}", ))) } } @@ -369,7 +368,7 @@ async fn format_source_files( Err(e) => { let _g = output_lock.lock(); eprintln!("Error formatting: {}", file_path.to_string_lossy()); - eprintln!(" {}", e); + eprintln!(" {e}"); } } Ok(()) @@ -719,7 +718,7 @@ mod test { &PathBuf::from("mod.ts"), "1", &Default::default(), - |_, file_text, _| Ok(Some(format!("1{}", file_text))), + |_, file_text, _| Ok(Some(format!("1{file_text}"))), ) .unwrap(); } diff --git a/cli/tools/info.rs b/cli/tools/info.rs index 21b3d03f7..f3de922c6 100644 --- a/cli/tools/info.rs +++ b/cli/tools/info.rs @@ -266,10 +266,7 @@ fn print_tree_node<TWrite: Write>( writeln!( writer, "{} {}", - colors::gray(format!( - "{}{}─{}", - prefix, sibling_connector, child_connector - )), + colors::gray(format!("{prefix}{sibling_connector}─{child_connector}")), child.text )?; let child_prefix = format!( diff --git a/cli/tools/init/mod.rs b/cli/tools/init/mod.rs index 12d5872f1..c12b7a286 100644 --- a/cli/tools/init/mod.rs +++ b/cli/tools/init/mod.rs @@ -18,7 +18,7 @@ fn create_file( .write(true) .create_new(true) .open(dir.join(filename)) - .with_context(|| format!("Failed to create {} file", filename))?; + .with_context(|| format!("Failed to create {filename} file"))?; file.write_all(content.as_bytes())?; Ok(()) } diff --git a/cli/tools/installer.rs b/cli/tools/installer.rs index 2d2584f54..cc9b5c696 100644 --- a/cli/tools/installer.rs +++ b/cli/tools/installer.rs @@ -41,8 +41,7 @@ fn validate_name(exec_name: &str) -> Result<(), AnyError> { Ok(()) } else { Err(generic_error(format!( - "Invalid executable name: {}", - exec_name + "Invalid executable name: {exec_name}" ))) } } @@ -53,11 +52,8 @@ fn validate_name(exec_name: &str) -> Result<(), AnyError> { /// A second compatible with git bash / MINGW64 /// Generate batch script to satisfy that. fn generate_executable_file(shim_data: &ShimData) -> Result<(), AnyError> { - let args: Vec<String> = shim_data - .args - .iter() - .map(|c| format!("\"{}\"", c)) - .collect(); + let args: Vec<String> = + shim_data.args.iter().map(|c| format!("\"{c}\"")).collect(); let template = format!( "% generated by deno install %\n@deno {} %*\n", args @@ -122,7 +118,7 @@ fn get_installer_root() -> Result<PathBuf, io::Error> { .ok_or_else(|| { io::Error::new( io::ErrorKind::NotFound, - format!("${} is not defined", home_env_var), + format!("${home_env_var} is not defined"), ) })?; home_path.push(".deno"); @@ -201,7 +197,7 @@ pub fn uninstall(name: String, root: Option<PathBuf>) -> Result<(), AnyError> { } if !removed { - return Err(generic_error(format!("No installation found for {}", name))); + return Err(generic_error(format!("No installation found for {name}"))); } // There might be some extra files to delete @@ -339,7 +335,7 @@ fn resolve_shim_data( Level::Debug => "debug", Level::Info => "info", _ => { - return Err(generic_error(format!("invalid log level {}", log_level))) + return Err(generic_error(format!("invalid log level {log_level}"))) } }; executable_args.push(log_level.to_string()); @@ -388,11 +384,11 @@ fn resolve_shim_data( } if let Some(inspect) = flags.inspect { - executable_args.push(format!("--inspect={}", inspect)); + executable_args.push(format!("--inspect={inspect}")); } if let Some(inspect_brk) = flags.inspect_brk { - executable_args.push(format!("--inspect-brk={}", inspect_brk)); + executable_args.push(format!("--inspect-brk={inspect_brk}")); } if let Some(import_map_path) = &flags.import_map_path { @@ -408,7 +404,7 @@ fn resolve_shim_data( extra_files.push(( copy_path, fs::read_to_string(config_path) - .with_context(|| format!("error reading {}", config_path))?, + .with_context(|| format!("error reading {config_path}"))?, )); } else { executable_args.push("--no-config".to_string()); @@ -1082,13 +1078,11 @@ mod tests { assert!(file_path.exists()); let mut expected_string = format!( - "--import-map '{}' --no-config 'http://localhost:4545/cat.ts'", - import_map_url + "--import-map '{import_map_url}' --no-config 'http://localhost:4545/cat.ts'" ); if cfg!(windows) { expected_string = format!( - "\"--import-map\" \"{}\" \"--no-config\" \"http://localhost:4545/cat.ts\"", - import_map_url + "\"--import-map\" \"{import_map_url}\" \"--no-config\" \"http://localhost:4545/cat.ts\"" ); } diff --git a/cli/tools/lint.rs b/cli/tools/lint.rs index ba30c546a..0f81ec89d 100644 --- a/cli/tools/lint.rs +++ b/cli/tools/lint.rs @@ -219,7 +219,7 @@ pub fn print_rules_list(json: bool) { }) .collect(); let json_str = serde_json::to_string_pretty(&json_rules).unwrap(); - println!("{}", json_str); + println!("{json_str}"); } else { // The rules should still be printed even if `--quiet` option is enabled, // so use `println!` here instead of `info!`. @@ -345,12 +345,12 @@ impl LintReporter for PrettyLintReporter { )), ); - eprintln!("{}\n", message); + eprintln!("{message}\n"); } fn visit_error(&mut self, file_path: &str, err: &AnyError) { - eprintln!("Error linting: {}", file_path); - eprintln!(" {}", err); + eprintln!("Error linting: {file_path}"); + eprintln!(" {err}"); } fn close(&mut self, check_count: usize) { @@ -393,8 +393,8 @@ impl LintReporter for CompactLintReporter { } fn visit_error(&mut self, file_path: &str, err: &AnyError) { - eprintln!("Error linting: {}", file_path); - eprintln!(" {}", err); + eprintln!("Error linting: {file_path}"); + eprintln!(" {err}"); } fn close(&mut self, check_count: usize) { diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index f8302367a..c9f019305 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -277,8 +277,7 @@ fn validate(input: &str) -> ValidationResult { | (Some(Token::DollarLBrace), Token::RBrace) => {} (Some(left), _) => { return ValidationResult::Invalid(Some(format!( - "Mismatched pairs: {:?} is not properly closed", - left + "Mismatched pairs: {left:?} is not properly closed" ))) } (None, _) => { @@ -460,7 +459,7 @@ impl ReplEditor { } self.errored_on_history_save.store(true, Relaxed); - eprintln!("Unable to save history file: {}", e); + eprintln!("Unable to save history file: {e}"); } } diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs index 780f16a6a..a9cb0132b 100644 --- a/cli/tools/repl/mod.rs +++ b/cli/tools/repl/mod.rs @@ -112,14 +112,11 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> { .await; // only output errors if let EvaluationOutput::Error(error_text) = output { - println!( - "Error in --eval-file file \"{}\": {}", - eval_file, error_text - ); + println!("Error in --eval-file file \"{eval_file}\": {error_text}"); } } Err(e) => { - println!("Error in --eval-file file \"{}\": {}", eval_file, e); + println!("Error in --eval-file file \"{eval_file}\": {e}"); } } } @@ -129,7 +126,7 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> { let output = repl_session.evaluate_line_and_get_output(&eval).await; // only output errors if let EvaluationOutput::Error(error_text) = output { - println!("Error in --eval flag: {}", error_text); + println!("Error in --eval flag: {error_text}"); } } @@ -166,7 +163,7 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> { break; } - println!("{}", output); + println!("{output}"); } Err(ReadlineError::Interrupted) => { if editor.should_exit_on_interrupt() { @@ -180,7 +177,7 @@ pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> { break; } Err(err) => { - println!("Error: {:?}", err); + println!("Error: {err:?}"); break; } } diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs index cb7d18c46..e288ab0e6 100644 --- a/cli/tools/repl/session.rs +++ b/cli/tools/repl/session.rs @@ -419,10 +419,7 @@ impl ReplSession { .text; let value = self - .evaluate_expression(&format!( - "'use strict'; void 0;\n{}", - transpiled_src - )) + .evaluate_expression(&format!("'use strict'; void 0;\n{transpiled_src}")) .await?; Ok(TsEvaluateResponse { diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index a0fa29e81..72f30aae9 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -94,7 +94,7 @@ async fn get_base_binary( } let target = target.unwrap_or_else(|| env!("TARGET").to_string()); - let binary_name = format!("deno-{}.zip", target); + let binary_name = format!("deno-{target}.zip"); let binary_path_suffix = if crate::version::is_canary() { format!("canary/{}/{}", crate::version::GIT_COMMIT_HASH, binary_name) @@ -127,7 +127,7 @@ async fn download_base_binary( output_directory: &Path, binary_path_suffix: &str, ) -> Result<(), AnyError> { - let download_url = format!("https://dl.deno.land/{}", binary_path_suffix); + let download_url = format!("https://dl.deno.land/{binary_path_suffix}"); let maybe_bytes = { let progress_bars = ProgressBar::new(ProgressBarStyle::DownloadBars); let progress = progress_bars.update(&download_url); @@ -164,7 +164,7 @@ async fn create_standalone_binary( let ca_data = match ps.options.ca_data() { Some(CaData::File(ca_file)) => { - Some(fs::read(ca_file).with_context(|| format!("Reading: {}", ca_file))?) + Some(fs::read(ca_file).with_context(|| format!("Reading: {ca_file}"))?) } Some(CaData::Bytes(bytes)) => Some(bytes.clone()), None => None, diff --git a/cli/tools/task.rs b/cli/tools/task.rs index 51fd377e4..0b611b9d3 100644 --- a/cli/tools/task.rs +++ b/cli/tools/task.rs @@ -56,7 +56,7 @@ pub async fn execute_script( .map(|a| format!("\"{}\"", a.replace('"', "\\\"").replace('$', "\\$"))) .collect::<Vec<_>>() .join(" "); - let script = format!("{} {}", script, additional_args); + let script = format!("{script} {additional_args}"); let script = script.trim(); log::info!( "{} {} {}", @@ -65,7 +65,7 @@ pub async fn execute_script( script, ); let seq_list = deno_task_shell::parser::parse(script) - .with_context(|| format!("Error parsing script '{}'.", task_name))?; + .with_context(|| format!("Error parsing script '{task_name}'."))?; // get the starting env vars (the PWD env var will be set by deno_task_shell) let mut env_vars = std::env::vars().collect::<HashMap<String, String>>(); @@ -81,7 +81,7 @@ pub async fn execute_script( let exit_code = deno_task_shell::execute(seq_list, env_vars, &cwd).await; Ok(exit_code) } else { - eprintln!("Task not found: {}", task_name); + eprintln!("Task not found: {task_name}"); print_available_tasks(tasks_config); Ok(1) } diff --git a/cli/tools/test.rs b/cli/tools/test.rs index c4c39ede3..e680d5718 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -323,7 +323,7 @@ impl PrettyTestReporter { if url.scheme() == "file" { if let Some(mut r) = self.cwd.make_relative(&url) { if !r.starts_with("../") { - r = format!("./{}", r); + r = format!("./{r}"); } return r; } @@ -513,7 +513,7 @@ impl PrettyTestReporter { ); print!(" {} ...", root.name); for name in ancestor_names { - print!(" {} ...", name); + print!(" {name} ..."); } print!(" {} ...", description.name); self.in_new_line = false; @@ -584,7 +584,7 @@ impl PrettyTestReporter { } println!("{}\n", colors::white_bold_on_red(" FAILURES ")); for failure_title in failure_titles { - println!("{}", failure_title); + println!("{failure_title}"); } } @@ -600,7 +600,7 @@ impl PrettyTestReporter { } else if count == 1 { " (1 step)".to_string() } else { - format!(" ({} steps)", count) + format!(" ({count} steps)") } }; diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index f34a30744..2caaa0e02 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -373,7 +373,7 @@ pub async fn upgrade( let archive_data = download_package(client, &download_url) .await - .with_context(|| format!("Failed downloading {}", download_url))?; + .with_context(|| format!("Failed downloading {download_url}"))?; log::info!("Deno is upgrading to version {}", &install_version); @@ -531,7 +531,7 @@ pub fn unpack_into_dir( })? .wait()? } - ext => panic!("Unsupported archive type: '{}'", ext), + ext => panic!("Unsupported archive type: '{ext}'"), }; assert!(unpack_status.success()); assert!(exe_path.exists()); diff --git a/cli/tools/vendor/build.rs b/cli/tools/vendor/build.rs index 830cb39f7..f418670b3 100644 --- a/cli/tools/vendor/build.rs +++ b/cli/tools/vendor/build.rs @@ -204,19 +204,15 @@ fn build_proxy_module_source( // for simplicity, always include the `export *` statement as it won't error // even when the module does not contain a named export - writeln!(text, "export * from \"{}\";", relative_specifier).unwrap(); + writeln!(text, "export * from \"{relative_specifier}\";").unwrap(); // add a default export if one exists in the module if let Some(parsed_source) = parsed_source_cache.get_parsed_source_from_module(module)? { if has_default_export(&parsed_source) { - writeln!( - text, - "export {{ default }} from \"{}\";", - relative_specifier - ) - .unwrap(); + writeln!(text, "export {{ default }} from \"{relative_specifier}\";") + .unwrap(); } } diff --git a/cli/tools/vendor/import_map.rs b/cli/tools/vendor/import_map.rs index 411a2e059..0897cbcf6 100644 --- a/cli/tools/vendor/import_map.rs +++ b/cli/tools/vendor/import_map.rs @@ -322,7 +322,7 @@ fn handle_remote_dep_specifier( if is_remote_specifier_text(text) { let base_specifier = mappings.base_specifier(specifier); if !text.starts_with(base_specifier.as_str()) { - panic!("Expected {} to start with {}", text, base_specifier); + panic!("Expected {text} to start with {base_specifier}"); } let sub_path = &text[base_specifier.as_str().len()..]; diff --git a/cli/tools/vendor/mappings.rs b/cli/tools/vendor/mappings.rs index 14705e51e..8cf6388d2 100644 --- a/cli/tools/vendor/mappings.rs +++ b/cli/tools/vendor/mappings.rs @@ -133,9 +133,7 @@ impl Mappings { self .mappings .get(specifier) - .unwrap_or_else(|| { - panic!("Could not find local path for {}", specifier) - }) + .unwrap_or_else(|| panic!("Could not find local path for {specifier}")) .to_path_buf() } } @@ -163,7 +161,7 @@ impl Mappings { .iter() .find(|s| child_specifier.as_str().starts_with(s.as_str())) .unwrap_or_else(|| { - panic!("Could not find base specifier for {}", child_specifier) + panic!("Could not find base specifier for {child_specifier}") }) } diff --git a/cli/tools/vendor/specifiers.rs b/cli/tools/vendor/specifiers.rs index d4f413c31..7418bcb8b 100644 --- a/cli/tools/vendor/specifiers.rs +++ b/cli/tools/vendor/specifiers.rs @@ -45,7 +45,7 @@ pub fn get_unique_path( let mut count = 2; // case insensitive comparison so the output works on case insensitive file systems while !unique_set.insert(path.to_string_lossy().to_lowercase()) { - path = path_with_stem_suffix(&original_path, &format!("_{}", count)); + path = path_with_stem_suffix(&original_path, &format!("_{count}")); count += 1; } path |
