diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 6d5ca8321e5d..434e0e4d7045 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs @@ -288,7 +288,7 @@ impl FlycheckActor { Some(c) => c, None => continue, }; - let formatted_command = format!("{:?}", command); + let formatted_command = format!("{command:?}"); tracing::debug!(?command, "will restart flycheck"); let (sender, receiver) = unbounded(); @@ -301,8 +301,7 @@ impl FlycheckActor { } Err(error) => { self.report_progress(Progress::DidFailToRestart(format!( - "Failed to run the following command: {} error={}", - formatted_command, error + "Failed to run the following command: {formatted_command} error={error}" ))); } } @@ -313,7 +312,7 @@ impl FlycheckActor { // Watcher finished let command_handle = self.command_handle.take().unwrap(); self.command_receiver.take(); - let formatted_handle = format!("{:?}", command_handle); + let formatted_handle = format!("{command_handle:?}"); let res = command_handle.join(); if let Err(error) = &res { diff --git a/crates/hir-ty/src/consteval/tests.rs b/crates/hir-ty/src/consteval/tests.rs index d1ffd5046c3f..1b4584a18d76 100644 --- a/crates/hir-ty/src/consteval/tests.rs +++ b/crates/hir-ty/src/consteval/tests.rs @@ -73,7 +73,7 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) { Ok(t) => t, Err(e) => { let err = pretty_print_err(e, db); - panic!("Error in evaluating goal: {}", err); + panic!("Error in evaluating goal: {err}"); } }; match &r.data(Interner).value { @@ -81,7 +81,7 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) { ConstScalar::Bytes(b, mm) => { check(b, mm); } - x => panic!("Expected number but found {:?}", x), + x => panic!("Expected number but found {x:?}"), }, _ => panic!("result of const eval wasn't a concrete const"), } @@ -89,7 +89,7 @@ fn check_answer(ra_fixture: &str, check: impl FnOnce(&[u8], &MemoryMap)) { fn pretty_print_err(e: ConstEvalError, db: TestDB) -> String { let mut err = String::new(); - let span_formatter = |file, range| format!("{:?} {:?}", file, range); + let span_formatter = |file, range| format!("{file:?} {range:?}"); match e { ConstEvalError::MirLowerError(e) => e.pretty_print(&mut err, &db, span_formatter), ConstEvalError::MirEvalError(e) => e.pretty_print(&mut err, &db, span_formatter), diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs index 5a9621bb69a4..0027eb56a856 100644 --- a/crates/hir-ty/src/display.rs +++ b/crates/hir-ty/src/display.rs @@ -670,7 +670,7 @@ fn render_const_scalar( TyKind::FnDef(..) => ty.hir_fmt(f), TyKind::Function(_) | TyKind::Raw(_, _) => { let it = u128::from_le_bytes(pad16(b, false)); - write!(f, "{:#X} as ", it)?; + write!(f, "{it:#X} as ")?; ty.hir_fmt(f) } TyKind::Array(ty, len) => { diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs index 2de1aa30c966..4ee96a66a396 100644 --- a/crates/hir-ty/src/mir/eval.rs +++ b/crates/hir-ty/src/mir/eval.rs @@ -363,7 +363,7 @@ impl MirEvalError { )?; } Either::Right(closure) => { - writeln!(f, "In {:?}", closure)?; + writeln!(f, "In {closure:?}")?; } } let source_map = db.body_with_source_map(*def).1; @@ -424,7 +424,7 @@ impl MirEvalError { | MirEvalError::StackOverflow | MirEvalError::CoerceUnsizedError(_) | MirEvalError::InternalError(_) - | MirEvalError::InvalidVTableId(_) => writeln!(f, "{:?}", err)?, + | MirEvalError::InvalidVTableId(_) => writeln!(f, "{err:?}")?, } Ok(()) } diff --git a/crates/hir-ty/src/mir/eval/tests.rs b/crates/hir-ty/src/mir/eval/tests.rs index 4abbda56cbb4..c3b35cd553da 100644 --- a/crates/hir-ty/src/mir/eval/tests.rs +++ b/crates/hir-ty/src/mir/eval/tests.rs @@ -77,7 +77,7 @@ fn check_panic(ra_fixture: &str, expected_panic: &str) { let (db, file_ids) = TestDB::with_many_files(ra_fixture); let file_id = *file_ids.last().unwrap(); let e = eval_main(&db, file_id).unwrap_err(); - assert_eq!(e.is_panic().unwrap_or_else(|| panic!("unexpected error: {:?}", e)), expected_panic); + assert_eq!(e.is_panic().unwrap_or_else(|| panic!("unexpected error: {e:?}")), expected_panic); } #[test] diff --git a/crates/hir-ty/src/mir/lower.rs b/crates/hir-ty/src/mir/lower.rs index 151f65cfbb8e..95b16ca8bc63 100644 --- a/crates/hir-ty/src/mir/lower.rs +++ b/crates/hir-ty/src/mir/lower.rs @@ -213,7 +213,7 @@ impl MirLowerError { | MirLowerError::LangItemNotFound(_) | MirLowerError::MutatingRvalue | MirLowerError::UnresolvedLabel - | MirLowerError::UnresolvedUpvar(_) => writeln!(f, "{:?}", self)?, + | MirLowerError::UnresolvedUpvar(_) => writeln!(f, "{self:?}")?, } Ok(()) } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 777be711a5e6..d28c45edd716 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2414,9 +2414,9 @@ impl Const { let value_signed = i128::from_le_bytes(mir::pad16(b, matches!(s, Scalar::Int(_)))); if value >= 10 { - return Ok(format!("{} ({:#X})", value_signed, value)); + return Ok(format!("{value_signed} ({value:#X})")); } else { - return Ok(format!("{}", value_signed)); + return Ok(format!("{value_signed}")); } } } diff --git a/crates/ide-assists/src/handlers/auto_import.rs b/crates/ide-assists/src/handlers/auto_import.rs index 3bd003a267a2..650b4279ea57 100644 --- a/crates/ide-assists/src/handlers/auto_import.rs +++ b/crates/ide-assists/src/handlers/auto_import.rs @@ -140,7 +140,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option< acc.add_group( &group_label, assist_id, - format!("Import `{}`", import_name), + format!("Import `{import_name}`"), range, |builder| { let scope = match scope.clone() { @@ -165,7 +165,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option< acc.add_group( &group_label, assist_id, - format!("Import `{} as _`", import_name), + format!("Import `{import_name} as _`"), range, |builder| { let scope = match scope.clone() { diff --git a/crates/ide-assists/src/handlers/bool_to_enum.rs b/crates/ide-assists/src/handlers/bool_to_enum.rs index 71436e658047..c95e24693d44 100644 --- a/crates/ide-assists/src/handlers/bool_to_enum.rs +++ b/crates/ide-assists/src/handlers/bool_to_enum.rs @@ -228,7 +228,7 @@ fn replace_usages( edit.replace( prefix_expr.syntax().text_range(), - format!("{} == Bool::False", inner_expr), + format!("{inner_expr} == Bool::False"), ); } else if let Some((record_field, initializer)) = name .as_name_ref() @@ -275,7 +275,7 @@ fn replace_usages( } else if let Some(receiver) = find_method_call_expr_usage(&name) { edit.replace( receiver.syntax().text_range(), - format!("({} == Bool::True)", receiver), + format!("({receiver} == Bool::True)"), ); } else if name.syntax().ancestors().find_map(ast::UseTree::cast).is_none() { // for any other usage in an expression, replace it with a check that it is the true variant diff --git a/crates/ide-assists/src/handlers/destructure_struct_binding.rs b/crates/ide-assists/src/handlers/destructure_struct_binding.rs index 9adbdd220c2b..761887155248 100644 --- a/crates/ide-assists/src/handlers/destructure_struct_binding.rs +++ b/crates/ide-assists/src/handlers/destructure_struct_binding.rs @@ -242,7 +242,7 @@ fn generate_field_names(ctx: &AssistContext<'_>, data: &StructEditData) -> Vec<( .iter() .enumerate() .map(|(index, _)| { - let new_name = new_field_name((format!("_{}", index)).into(), &data.names_in_scope); + let new_name = new_field_name((format!("_{index}")).into(), &data.names_in_scope); (index.to_string().into(), new_name) }) .collect(), diff --git a/crates/ide-assists/src/handlers/generate_delegate_trait.rs b/crates/ide-assists/src/handlers/generate_delegate_trait.rs index 748acb46efbd..19521b8a4b79 100644 --- a/crates/ide-assists/src/handlers/generate_delegate_trait.rs +++ b/crates/ide-assists/src/handlers/generate_delegate_trait.rs @@ -758,7 +758,7 @@ fn ty_assoc_item(item: syntax::ast::TypeAlias, qual_path_ty: Path) -> Option ast::Path { - make::path_from_text(&format!("{}::{}", qual_path_ty, path_expr_seg)) + make::path_from_text(&format!("{qual_path_ty}::{path_expr_seg}")) } #[cfg(test)] diff --git a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs index e90a032f1cb4..60214aaaf69e 100644 --- a/crates/ide-assists/src/handlers/generate_getter_or_setter.rs +++ b/crates/ide-assists/src/handlers/generate_getter_or_setter.rs @@ -47,7 +47,7 @@ pub(crate) fn generate_setter(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt } // Prepend set_ to fn names. - fn_names.iter_mut().for_each(|name| *name = format!("set_{}", name)); + fn_names.iter_mut().for_each(|name| *name = format!("set_{name}")); // Return early if we've found an existing fn let impl_def = find_struct_impl(ctx, &ast::Adt::Struct(strukt.clone()), &fn_names)?; diff --git a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs b/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs index 91eaa96b6cb0..6aa561ad7f03 100644 --- a/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs +++ b/crates/ide-assists/src/handlers/generate_mut_trait_impl.rs @@ -105,7 +105,7 @@ pub(crate) fn generate_mut_trait_impl(acc: &mut Assists, ctx: &AssistContext<'_> "Generate `IndexMut` impl from this `Index` trait", target, |edit| { - edit.insert(target.start(), format!("$0{}\n\n", impl_def)); + edit.insert(target.start(), format!("$0{impl_def}\n\n")); }, ) } diff --git a/crates/ide-assists/src/handlers/into_to_qualified_from.rs b/crates/ide-assists/src/handlers/into_to_qualified_from.rs index dee74afcbe24..e405af5533d5 100644 --- a/crates/ide-assists/src/handlers/into_to_qualified_from.rs +++ b/crates/ide-assists/src/handlers/into_to_qualified_from.rs @@ -67,9 +67,9 @@ pub(crate) fn into_to_qualified_from(acc: &mut Assists, ctx: &AssistContext<'_>) edit.replace( method_call.syntax().text_range(), if sc.chars().all(|c| c.is_alphanumeric() || c == ':') { - format!("{}::from({})", sc, receiver) + format!("{sc}::from({receiver})") } else { - format!("<{}>::from({})", sc, receiver) + format!("<{sc}>::from({receiver})") }, ); }, diff --git a/crates/ide-assists/src/handlers/merge_nested_if.rs b/crates/ide-assists/src/handlers/merge_nested_if.rs index 2f3136f027b0..7a0037fa202b 100644 --- a/crates/ide-assists/src/handlers/merge_nested_if.rs +++ b/crates/ide-assists/src/handlers/merge_nested_if.rs @@ -86,7 +86,7 @@ pub(crate) fn merge_nested_if(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opt nested_if_cond.syntax().text().to_string() }; - let replace_cond = format!("{} && {}", cond_text, nested_if_cond_text); + let replace_cond = format!("{cond_text} && {nested_if_cond_text}"); edit.replace(cond_range, replace_cond); edit.replace(then_branch_range, nested_if_then_branch.syntax().text()); diff --git a/crates/ide-assists/src/handlers/remove_parentheses.rs b/crates/ide-assists/src/handlers/remove_parentheses.rs index 99c55e9ff7c0..799d36be93e4 100644 --- a/crates/ide-assists/src/handlers/remove_parentheses.rs +++ b/crates/ide-assists/src/handlers/remove_parentheses.rs @@ -48,7 +48,7 @@ pub(crate) fn remove_parentheses(acc: &mut Assists, ctx: &AssistContext<'_>) -> } None => false, }; - let expr = if need_to_add_ws { format!(" {}", expr) } else { expr.to_string() }; + let expr = if need_to_add_ws { format!(" {expr}") } else { expr.to_string() }; builder.replace(parens.syntax().text_range(), expr) }, diff --git a/crates/ide-completion/src/completions/postfix/format_like.rs b/crates/ide-completion/src/completions/postfix/format_like.rs index fd50fd4e8c5c..2755329bb31a 100644 --- a/crates/ide-completion/src/completions/postfix/format_like.rs +++ b/crates/ide-completion/src/completions/postfix/format_like.rs @@ -65,7 +65,7 @@ pub(crate) fn add_format_like_completions( let exprs = with_placeholders(exprs); for (label, macro_name) in KINDS { let snippet = if exprs.is_empty() { - format!(r#"{}({})"#, macro_name, out) + format!(r#"{macro_name}({out})"#) } else { format!(r#"{}({}, {})"#, macro_name, out, exprs.join(", ")) }; @@ -108,7 +108,7 @@ mod tests { for (kind, input, output) in test_vector { let (parsed_string, _exprs) = parse_format_exprs(input).unwrap(); - let snippet = format!(r#"{}("{}")"#, kind, parsed_string); + let snippet = format!(r#"{kind}("{parsed_string}")"#); assert_eq!(&snippet, output); } } diff --git a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs index 132b93df10ab..2b8779044fbc 100644 --- a/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs +++ b/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs @@ -37,7 +37,7 @@ impl State { self.names.insert(name.clone(), 1); 1 }; - make::name(&format!("{}{}", name, count)) + make::name(&format!("{name}{count}")) } fn serde_derive(&self) -> String { diff --git a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs index 00710ef50760..be1e6ed57227 100644 --- a/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs +++ b/crates/ide-diagnostics/src/handlers/trait_impl_redundant_assoc_item.rs @@ -27,7 +27,7 @@ pub(crate) fn trait_impl_redundant_assoc_item( hir::AssocItem::Function(id) => { let function = id; ( - format!("`fn {}`", redundant_assoc_item_name), + format!("`fn {redundant_assoc_item_name}`"), function .source(db) .map(|it| it.syntax().value.text_range()) @@ -38,7 +38,7 @@ pub(crate) fn trait_impl_redundant_assoc_item( hir::AssocItem::Const(id) => { let constant = id; ( - format!("`const {}`", redundant_assoc_item_name), + format!("`const {redundant_assoc_item_name}`"), constant .source(db) .map(|it| it.syntax().value.text_range()) @@ -49,7 +49,7 @@ pub(crate) fn trait_impl_redundant_assoc_item( hir::AssocItem::TypeAlias(id) => { let type_alias = id; ( - format!("`type {}`", redundant_assoc_item_name), + format!("`type {redundant_assoc_item_name}`"), type_alias .source(db) .map(|it| it.syntax().value.text_range()) diff --git a/crates/ide-diagnostics/src/handlers/unresolved_method.rs b/crates/ide-diagnostics/src/handlers/unresolved_method.rs index 0614fdc5514a..42211cdbe5d4 100644 --- a/crates/ide-diagnostics/src/handlers/unresolved_method.rs +++ b/crates/ide-diagnostics/src/handlers/unresolved_method.rs @@ -161,12 +161,11 @@ fn assoc_func_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) - // we could omit generic parameters cause compiler can deduce it automatically if !need_to_take_receiver_as_first_arg && !generic_parameters.is_empty() { let generic_parameters = generic_parameters.join(", "); - receiver_type_adt_name = - format!("{}::<{}>", receiver_type_adt_name, generic_parameters); + receiver_type_adt_name = format!("{receiver_type_adt_name}::<{generic_parameters}>"); } let method_name = call.name_ref()?; - let assoc_func_call = format!("{}::{}()", receiver_type_adt_name, method_name); + let assoc_func_call = format!("{receiver_type_adt_name}::{method_name}()"); let assoc_func_call = make::expr_path(make::path_from_text(&assoc_func_call)); @@ -184,8 +183,7 @@ fn assoc_func_fix(ctx: &DiagnosticsContext<'_>, d: &hir::UnresolvedMethodCall) - Some(Assist { id: AssistId("method_call_to_assoc_func_call_fix", AssistKind::QuickFix), label: Label::new(format!( - "Use associated func call instead: `{}`", - assoc_func_call_expr_string + "Use associated func call instead: `{assoc_func_call_expr_string}`" )), group: None, target: range, diff --git a/crates/ide/src/interpret_function.rs b/crates/ide/src/interpret_function.rs index df444a3f4d06..7bd2da9f88a2 100644 --- a/crates/ide/src/interpret_function.rs +++ b/crates/ide/src/interpret_function.rs @@ -43,7 +43,7 @@ fn find_and_interpret(db: &RootDatabase, position: FilePosition) -> Option"); match db.line_index(file_id).try_line_col(text_range.start()) { Some(line_col) => format!("file://{path}#{}:{}", line_col.line + 1, line_col.col), - None => format!("file://{path} range {:?}", text_range), + None => format!("file://{path} range {text_range:?}"), } }; Some(def.eval(db, span_formatter)) diff --git a/crates/ide/src/view_memory_layout.rs b/crates/ide/src/view_memory_layout.rs index a229bc87c893..826447d058df 100644 --- a/crates/ide/src/view_memory_layout.rs +++ b/crates/ide/src/view_memory_layout.rs @@ -40,7 +40,7 @@ impl fmt::Display for RecursiveMemoryLayout { "{}: {} (size: {}, align: {}, field offset: {})\n", node.item_name, node.typename, node.size, node.alignment, node.offset ); - write!(fmt, "{}", out)?; + write!(fmt, "{out}")?; if node.children_start != -1 { for j in nodes[idx].children_start ..(nodes[idx].children_start + nodes[idx].children_len as i64) diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 4e5837312fe2..b342e35488fe 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -418,7 +418,7 @@ fn delimited( } if !p.eat(delim) { if p.at_ts(first_set) { - p.error(format!("expected {:?}", delim)); + p.error(format!("expected {delim:?}")); } else { break; } diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index 2d3653401d2f..4c79d67d5b8b 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -106,7 +106,7 @@ impl AbsPathBuf { /// Panics if `path` is not absolute. pub fn assert(path: Utf8PathBuf) -> AbsPathBuf { AbsPathBuf::try_from(path) - .unwrap_or_else(|path| panic!("expected absolute path, got {}", path)) + .unwrap_or_else(|path| panic!("expected absolute path, got {path}")) } /// Wrap the given absolute path in `AbsPathBuf` diff --git a/crates/proc-macro-api/src/process.rs b/crates/proc-macro-api/src/process.rs index dce086d4299b..718a96dc80fe 100644 --- a/crates/proc-macro-api/src/process.rs +++ b/crates/proc-macro-api/src/process.rs @@ -50,8 +50,7 @@ impl ProcMacroProcessSrv { Ok(v) if v > CURRENT_API_VERSION => Err(io::Error::new( io::ErrorKind::Other, format!( - "proc-macro server's api version ({}) is newer than rust-analyzer's ({})", - v, CURRENT_API_VERSION + "proc-macro server's api version ({v}) is newer than rust-analyzer's ({CURRENT_API_VERSION})" ), )), Ok(v) => { diff --git a/crates/project-model/src/sysroot.rs b/crates/project-model/src/sysroot.rs index 653e7157bcb3..1eeec4cedeba 100644 --- a/crates/project-model/src/sysroot.rs +++ b/crates/project-model/src/sysroot.rs @@ -219,8 +219,7 @@ impl Sysroot { ", try running `rustup component add rust-src` to possibly fix this" }; sysroot.error = Some(format!( - "sysroot at `{}` is missing a `core` library{var_note}", - src_root, + "sysroot at `{src_root}` is missing a `core` library{var_note}", )); } } diff --git a/crates/project-model/src/tests.rs b/crates/project-model/src/tests.rs index a6730863d6b2..2762de5997ae 100644 --- a/crates/project-model/src/tests.rs +++ b/crates/project-model/src/tests.rs @@ -126,7 +126,7 @@ fn replace_fake_sys_root(s: &mut String) { let fake_sysroot_path = get_test_path("fake-sysroot"); let fake_sysroot_path = if cfg!(windows) { let normalized_path = fake_sysroot_path.as_str().replace('\\', r#"\\"#); - format!(r#"{}\\"#, normalized_path) + format!(r#"{normalized_path}\\"#) } else { format!("{}/", fake_sysroot_path.as_str()) }; diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index bded41932c03..932f2e70b3c9 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -479,7 +479,7 @@ impl flags::AnalysisStats { .or_insert(1); } else { acc.syntax_errors += 1; - bar.println(format!("Syntax error: \n{}", err)); + bar.println(format!("Syntax error: \n{err}")); } } } diff --git a/crates/rust-analyzer/src/cli/run_tests.rs b/crates/rust-analyzer/src/cli/run_tests.rs index a2d0dcc599ca..10cb2d5ad6e3 100644 --- a/crates/rust-analyzer/src/cli/run_tests.rs +++ b/crates/rust-analyzer/src/cli/run_tests.rs @@ -49,7 +49,7 @@ impl flags::RunTests { let mut sw_all = StopWatch::start(); for test in tests { let full_name = full_name_of_item(db, test.module(db), test.name(db)); - println!("test {}", full_name); + println!("test {full_name}"); if test.is_ignore(db) { println!("ignored"); ignore_count += 1; @@ -62,7 +62,7 @@ impl flags::RunTests { } else { fail_count += 1; } - println!("{}", result); + println!("{result}"); eprintln!("{:<20} {}", format!("test {}", full_name), sw_one.elapsed()); } println!("{pass_count} passed, {fail_count} failed, {ignore_count} ignored"); diff --git a/crates/rust-analyzer/src/cli/rustc_tests.rs b/crates/rust-analyzer/src/cli/rustc_tests.rs index e9a4db7a2b0d..31565878d845 100644 --- a/crates/rust-analyzer/src/cli/rustc_tests.rs +++ b/crates/rust-analyzer/src/cli/rustc_tests.rs @@ -220,8 +220,8 @@ impl Tester { self.pass_count += 1; } else { println!("{p:?} FAIL"); - println!("actual (r-a) = {:?}", actual); - println!("expected (rustc) = {:?}", expected); + println!("actual (r-a) = {actual:?}"); + println!("expected (rustc) = {expected:?}"); self.fail_count += 1; } } diff --git a/crates/rust-analyzer/src/tracing/hprof.rs b/crates/rust-analyzer/src/tracing/hprof.rs index 73f94671f2da..978dcd67faf1 100644 --- a/crates/rust-analyzer/src/tracing/hprof.rs +++ b/crates/rust-analyzer/src/tracing/hprof.rs @@ -199,7 +199,7 @@ impl Node { let _ = write!(out, " ({} calls)", self.count); } - eprintln!("{}", out); + eprintln!("{out}"); for child in &self.children { child.go(level + 1, filter) diff --git a/crates/salsa/salsa-macros/src/query_group.rs b/crates/salsa/salsa-macros/src/query_group.rs index 659797d6d4a4..c04b30691671 100644 --- a/crates/salsa/salsa-macros/src/query_group.rs +++ b/crates/salsa/salsa-macros/src/query_group.rs @@ -20,7 +20,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream let input_span = input.span(); let (trait_attrs, salsa_attrs) = filter_attrs(input.attrs); if !salsa_attrs.is_empty() { - return Error::new(input_span, format!("unsupported attributes: {:?}", salsa_attrs)) + return Error::new(input_span, format!("unsupported attributes: {salsa_attrs:?}")) .to_compile_error() .into(); } @@ -78,7 +78,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream num_storages += 1; } _ => { - return Error::new(span, format!("unknown salsa attribute `{}`", name)) + return Error::new(span, format!("unknown salsa attribute `{name}`")) .to_compile_error() .into(); } @@ -111,7 +111,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream _ => { return Error::new( sig_span, - format!("first argument of query `{}` must be `&self`", query_name), + format!("first argument of query `{query_name}` must be `&self`"), ) .to_compile_error() .into(); @@ -130,7 +130,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream arg => { return Error::new( arg.span(), - format!("unsupported argument `{:?}` of `{}`", arg, query_name,), + format!("unsupported argument `{arg:?}` of `{query_name}`",), ) .to_compile_error() .into(); @@ -144,7 +144,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream ref ret => { return Error::new( ret.span(), - format!("unsupported return type `{:?}` of `{}`", ret, query_name), + format!("unsupported return type `{ret:?}` of `{query_name}`"), ) .to_compile_error() .into(); @@ -169,7 +169,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream let lookup_keys = vec![(parse_quote! { key }, value.clone())]; Some(Query { query_type: lookup_query_type, - query_name: format!("{}", lookup_fn_name), + query_name: format!("{lookup_fn_name}"), fn_name: lookup_fn_name, receiver: self_receiver.clone(), attrs: vec![], // FIXME -- some automatically generated docs on this method? @@ -274,8 +274,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream *Note:* Setting values will trigger cancellation of any ongoing queries; this method blocks until those queries have been cancelled. - ", - fn_name = fn_name + " ); let set_constant_fn_docs = format!( @@ -290,8 +289,7 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream *Note:* Setting values will trigger cancellation of any ongoing queries; this method blocks until those queries have been cancelled. - ", - fn_name = fn_name + " ); query_fn_declarations.extend(quote! { diff --git a/crates/salsa/tests/cycles.rs b/crates/salsa/tests/cycles.rs index ea5d15a250f5..e9bddfc630e4 100644 --- a/crates/salsa/tests/cycles.rs +++ b/crates/salsa/tests/cycles.rs @@ -162,7 +162,7 @@ fn extract_cycle(f: impl FnOnce() + UnwindSafe) -> salsa::Cycle { return cycle.clone(); } } - panic!("unexpected value: {:?}", v) + panic!("unexpected value: {v:?}") } #[test] diff --git a/crates/salsa/tests/incremental/constants.rs b/crates/salsa/tests/incremental/constants.rs index ea0eb8197860..32bfbc4564b8 100644 --- a/crates/salsa/tests/incremental/constants.rs +++ b/crates/salsa/tests/incremental/constants.rs @@ -13,12 +13,12 @@ pub(crate) trait ConstantsDatabase: TestContext { } fn add(db: &dyn ConstantsDatabase, key1: char, key2: char) -> usize { - db.log().add(format!("add({}, {})", key1, key2)); + db.log().add(format!("add({key1}, {key2})")); db.input(key1) + db.input(key2) } fn add3(db: &dyn ConstantsDatabase, key1: char, key2: char, key3: char) -> usize { - db.log().add(format!("add3({}, {}, {})", key1, key2, key3)); + db.log().add(format!("add3({key1}, {key2}, {key3})")); db.add(key1, key2) + db.input(key3) } diff --git a/crates/salsa/tests/incremental/implementation.rs b/crates/salsa/tests/incremental/implementation.rs index 19752bba005a..84349134415a 100644 --- a/crates/salsa/tests/incremental/implementation.rs +++ b/crates/salsa/tests/incremental/implementation.rs @@ -26,7 +26,7 @@ pub(crate) struct TestContextImpl { impl TestContextImpl { #[track_caller] pub(crate) fn assert_log(&self, expected_log: &[&str]) { - let expected_text = &format!("{:#?}", expected_log); + let expected_text = &format!("{expected_log:#?}"); let actual_text = &format!("{:#?}", self.log().take()); if expected_text == actual_text { @@ -36,9 +36,9 @@ impl TestContextImpl { #[allow(clippy::print_stdout)] for diff in dissimilar::diff(expected_text, actual_text) { match diff { - dissimilar::Chunk::Delete(l) => println!("-{}", l), - dissimilar::Chunk::Equal(l) => println!(" {}", l), - dissimilar::Chunk::Insert(r) => println!("+{}", r), + dissimilar::Chunk::Delete(l) => println!("-{l}"), + dissimilar::Chunk::Equal(l) => println!(" {l}"), + dissimilar::Chunk::Insert(r) => println!("+{r}"), } } diff --git a/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs b/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs index 2930c4e379ff..3c73852eafb8 100644 --- a/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs +++ b/crates/salsa/tests/parallel/parallel_cycle_none_recover.rs @@ -33,7 +33,7 @@ fn parallel_cycle_none_recover() { "#]] .assert_debug_eq(&c.unexpected_participants(&db)); } else { - panic!("b failed in an unexpected way: {:?}", err_b); + panic!("b failed in an unexpected way: {err_b:?}"); } // We expect A to propagate a panic, which causes us to use the sentinel diff --git a/crates/salsa/tests/parallel/race.rs b/crates/salsa/tests/parallel/race.rs index e875de998f8d..c53d4b464ea0 100644 --- a/crates/salsa/tests/parallel/race.rs +++ b/crates/salsa/tests/parallel/race.rs @@ -28,7 +28,7 @@ fn in_par_get_set_race() { // cancellation, it'll unwind. let result1 = thread1.join().unwrap(); if let Ok(value1) = result1 { - assert!(value1 == 111 || value1 == 1011, "illegal result {}", value1); + assert!(value1 == 111 || value1 == 1011, "illegal result {value1}"); } // thread2 can not observe a cancellation because it performs a diff --git a/crates/span/src/lib.rs b/crates/span/src/lib.rs index 8ca7bc2d38a1..74693a270be9 100644 --- a/crates/span/src/lib.rs +++ b/crates/span/src/lib.rs @@ -218,7 +218,7 @@ impl From for HirFileId { fn from(MacroFileId { macro_call_id: MacroCallId(id) }: MacroFileId) -> Self { _ = Self::ASSERT_MAX_FILE_ID_IS_SAME; let id = id.as_u32(); - assert!(id <= Self::MAX_HIR_FILE_ID, "MacroCallId index {} is too large", id); + assert!(id <= Self::MAX_HIR_FILE_ID, "MacroCallId index {id} is too large"); HirFileId(id | Self::MACRO_FILE_TAG_MASK) } } diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 186f1b01da42..92a53c0f9e6c 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -172,7 +172,7 @@ pub fn ty_alias( assignment: Option<(ast::Type, Option)>, ) -> ast::TypeAlias { let mut s = String::new(); - s.push_str(&format!("type {}", ident)); + s.push_str(&format!("type {ident}")); if let Some(list) = generic_param_list { s.push_str(&list.to_string()); @@ -297,7 +297,7 @@ pub fn impl_trait( }; let where_clause = merge_where_clause(ty_where_clause, trait_where_clause) - .map_or_else(|| " ".to_owned(), |wc| format!("\n{}\n", wc)); + .map_or_else(|| " ".to_owned(), |wc| format!("\n{wc}\n")); let body = match body { Some(bd) => bd.iter().map(|elem| elem.to_string()).join(""), diff --git a/crates/test-fixture/src/lib.rs b/crates/test-fixture/src/lib.rs index be9961120d52..e65186d37715 100644 --- a/crates/test-fixture/src/lib.rs +++ b/crates/test-fixture/src/lib.rs @@ -196,7 +196,7 @@ impl ChangeFixture { origin, ); let prev = crates.insert(crate_name.clone(), crate_id); - assert!(prev.is_none(), "multiple crates with same name: {}", crate_name); + assert!(prev.is_none(), "multiple crates with same name: {crate_name}"); for dep in meta.deps { let prelude = match &meta.extern_prelude { Some(v) => v.contains(&dep), diff --git a/crates/test-utils/src/fixture.rs b/crates/test-utils/src/fixture.rs index aafe4fb5b10b..9871fd2cf0aa 100644 --- a/crates/test-utils/src/fixture.rs +++ b/crates/test-utils/src/fixture.rs @@ -450,7 +450,7 @@ impl MiniCore { } if !active_regions.is_empty() { - panic!("unclosed regions: {:?} Add an `endregion` comment", active_regions); + panic!("unclosed regions: {active_regions:?} Add an `endregion` comment"); } for flag in &self.valid_flags { diff --git a/lib/lsp-server/src/lib.rs b/lib/lsp-server/src/lib.rs index 5dc052b58755..4069e6f2c09a 100644 --- a/lib/lsp-server/src/lib.rs +++ b/lib/lsp-server/src/lib.rs @@ -433,8 +433,7 @@ mod tests { initialize_start_test(TestCase { test_messages: vec![notification_msg.clone()], expected_resp: Err(ProtocolError::new(format!( - "expected initialize request, got {:?}", - notification_msg + "expected initialize request, got {notification_msg:?}" ))), }); } diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 285abb9efcb4..9a7785dd4382 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs @@ -64,7 +64,7 @@ impl flags::Metrics { }; let mut file = - fs::File::options().write(true).create(true).open(format!("target/{}.json", name))?; + fs::File::options().write(true).create(true).open(format!("target/{name}.json"))?; writeln!(file, "{}", metrics.json())?; eprintln!("{metrics:#?}"); Ok(())