Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7705167

Browse files
committed
use inline format args
1 parent 17cc78f commit 7705167

File tree

21 files changed

+61
-109
lines changed

21 files changed

+61
-109
lines changed

crates/flycheck/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,7 @@ impl CargoHandle {
408408
Ok(())
409409
} else {
410410
Err(io::Error::new(io::ErrorKind::Other, format!(
411-
"Cargo watcher failed, the command produced no valid metadata (exit code: {:?}):\n{}",
412-
exit_status, error
411+
"Cargo watcher failed, the command produced no valid metadata (exit code: {exit_status:?}):\n{error}"
413412
)))
414413
}
415414
}

crates/hir-def/src/data.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ impl TraitData {
234234
let item_tree = tree_id.item_tree(db);
235235
let tr_def = &item_tree[tree_id.value];
236236
let _cx = stdx::panic_context::enter(format!(
237-
"trait_data_query({:?} -> {:?} -> {:?})",
238-
tr, tr_loc, tr_def
237+
"trait_data_query({tr:?} -> {tr_loc:?} -> {tr_def:?})"
239238
));
240239
let name = tr_def.name.clone();
241240
let is_auto = tr_def.is_auto;
@@ -619,10 +618,8 @@ impl<'a> AssocItemCollector<'a> {
619618

620619
let ast_id_map = self.db.ast_id_map(self.expander.current_file_id());
621620
let call = ast_id_map.get(call.ast_id).to_node(&root);
622-
let _cx = stdx::panic_context::enter(format!(
623-
"collect_items MacroCall: {}",
624-
call
625-
));
621+
let _cx =
622+
stdx::panic_context::enter(format!("collect_items MacroCall: {call}"));
626623
let res = self.expander.enter_expand::<ast::MacroItems>(self.db, call);
627624

628625
if let Ok(ExpandResult { value: Some((mark, _)), .. }) = res {

crates/hir-ty/src/lower.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,8 +1796,7 @@ pub(crate) fn impl_self_ty_query(db: &dyn HirDatabase, impl_id: ImplId) -> Binde
17961796
let impl_data = db.impl_data(impl_id);
17971797
let resolver = impl_id.resolver(db.upcast());
17981798
let _cx = stdx::panic_context::enter(format!(
1799-
"impl_self_ty_query({:?} -> {:?} -> {:?})",
1800-
impl_id, impl_loc, impl_data
1799+
"impl_self_ty_query({impl_id:?} -> {impl_loc:?} -> {impl_data:?})"
18011800
));
18021801
let generics = generics(db.upcast(), impl_id.into());
18031802
let ctx =
@@ -1834,8 +1833,7 @@ pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<
18341833
let impl_data = db.impl_data(impl_id);
18351834
let resolver = impl_id.resolver(db.upcast());
18361835
let _cx = stdx::panic_context::enter(format!(
1837-
"impl_trait_query({:?} -> {:?} -> {:?})",
1838-
impl_id, impl_loc, impl_data
1836+
"impl_trait_query({impl_id:?} -> {impl_loc:?} -> {impl_data:?})"
18391837
));
18401838
let ctx =
18411839
TyLoweringContext::new(db, &resolver).with_type_param_mode(ParamLoweringMode::Variable);

crates/ide-assists/src/tests/sourcegen.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ impl Assist {
9595
let id = block.id;
9696
assert!(
9797
id.chars().all(|it| it.is_ascii_lowercase() || it == '_'),
98-
"invalid assist id: {:?}",
99-
id
98+
"invalid assist id: {id:?}"
10099
);
101100
let mut lines = block.contents.iter().peekable();
102101
let location = sourcegen::Location { file: path.to_path_buf(), line: block.line };

crates/ide-completion/src/completions/attribute.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,7 @@ fn attributes_are_sorted() {
371371
attrs.for_each(|next| {
372372
assert!(
373373
prev < next,
374-
r#"ATTRIBUTES array is not sorted, "{}" should come after "{}""#,
375-
prev,
376-
next
374+
r#"ATTRIBUTES array is not sorted, "{prev}" should come after "{next}""#
377375
);
378376
prev = next;
379377
});

crates/ide-completion/src/completions/env_vars.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,26 @@ mod tests {
6868
&format!(
6969
r#"
7070
#[rustc_builtin_macro]
71-
macro_rules! {} {{
71+
macro_rules! {macro_name} {{
7272
($var:literal) => {{ 0 }}
7373
}}
7474
7575
fn main() {{
76-
let foo = {}!("CAR$0");
76+
let foo = {macro_name}!("CAR$0");
7777
}}
78-
"#,
79-
macro_name, macro_name
78+
"#
8079
),
8180
&format!(
8281
r#"
8382
#[rustc_builtin_macro]
84-
macro_rules! {} {{
83+
macro_rules! {macro_name} {{
8584
($var:literal) => {{ 0 }}
8685
}}
8786
8887
fn main() {{
89-
let foo = {}!("CARGO_BIN_NAME");
88+
let foo = {macro_name}!("CARGO_BIN_NAME");
9089
}}
91-
"#,
92-
macro_name, macro_name
90+
"#
9391
),
9492
);
9593
}

crates/ide-completion/src/completions/item_list/trait_impl.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,10 @@ trait Test {{
845845
struct T;
846846
847847
impl Test for T {{
848-
{}
849-
{}
848+
{hint}
849+
{next_sibling}
850850
}}
851-
"#,
852-
hint, next_sibling
851+
"#
853852
),
854853
&format!(
855854
r#"
@@ -861,11 +860,10 @@ trait Test {{
861860
struct T;
862861
863862
impl Test for T {{
864-
{}
865-
{}
863+
{completed}
864+
{next_sibling}
866865
}}
867-
"#,
868-
completed, next_sibling
866+
"#
869867
),
870868
)
871869
};
@@ -905,10 +903,9 @@ struct T;
905903
impl Foo for T {{
906904
// Comment
907905
#[bar]
908-
{}
906+
{hint}
909907
}}
910-
"#,
911-
hint
908+
"#
912909
),
913910
&format!(
914911
r#"
@@ -922,10 +919,9 @@ struct T;
922919
impl Foo for T {{
923920
// Comment
924921
#[bar]
925-
{}
922+
{completed}
926923
}}
927-
"#,
928-
completed
924+
"#
929925
),
930926
)
931927
};

crates/ide-completion/src/completions/postfix.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ pub(crate) fn complete_postfix(
153153
"match",
154154
"match expr {}",
155155
&format!(
156-
"match {} {{\n Some(${{1:_}}) => {{$2}},\n None => {{$0}},\n}}",
157-
receiver_text
156+
"match {receiver_text} {{\n Some(${{1:_}}) => {{$2}},\n None => {{$0}},\n}}"
158157
),
159158
)
160159
.add_to(acc);

crates/proc-macro-srv/src/tests/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ fn assert_expand_impl(macro_name: &str, input: &str, attr: Option<&str>, expect:
3030
let attr = attr.map(|attr| parse_string(attr).unwrap().into_subtree());
3131

3232
let res = expander.expand(macro_name, &fixture.into_subtree(), attr.as_ref()).unwrap();
33-
expect.assert_eq(&format!("{:?}", res));
33+
expect.assert_eq(&format!("{res:?}"));
3434
}
3535

3636
pub(crate) fn list() -> Vec<String> {
3737
let dylib_path = proc_macro_test_dylib_path();
3838
let mut srv = ProcMacroSrv::default();
3939
let res = srv.list_macros(&dylib_path).unwrap();
40-
res.into_iter().map(|(name, kind)| format!("{} [{:?}]", name, kind)).collect()
40+
res.into_iter().map(|(name, kind)| format!("{name} [{kind:?}]")).collect()
4141
}

crates/profile/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Drop for CpuSpan {
118118
eprintln!("Profile rendered to:\n\n {}\n", svg.display());
119119
}
120120
_ => {
121-
eprintln!("Failed to run:\n\n {:?}\n", cmd);
121+
eprintln!("Failed to run:\n\n {cmd:?}\n");
122122
}
123123
}
124124
}

crates/project-model/src/build_scripts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ impl WorkspaceBuildScripts {
303303
Ok(it) => acc.push(it),
304304
Err(err) => {
305305
push_err(&format!(
306-
"invalid cfg from cargo-metadata: {}",
307-
err
306+
"invalid cfg from cargo-metadata: {err}"
308307
));
309308
return;
310309
}

crates/rust-analyzer/src/config.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,9 +1908,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
19081908
let doc = doc.trim_end_matches('\n');
19091909
assert!(
19101910
doc.ends_with('.') && doc.starts_with(char::is_uppercase),
1911-
"bad docs for {}: {:?}",
1912-
field,
1913-
doc
1911+
"bad docs for {field}: {doc:?}"
19141912
);
19151913
let default = default.parse::<serde_json::Value>().unwrap();
19161914

@@ -2213,17 +2211,16 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
22132211
let doc = doc_comment_to_string(doc);
22142212
if default.contains('\n') {
22152213
format!(
2216-
r#"[[{}]]{}::
2214+
r#"[[{name}]]{name}::
22172215
+
22182216
--
22192217
Default:
22202218
----
2221-
{}
2219+
{default}
22222220
----
2223-
{}
2221+
{doc}
22242222
--
2225-
"#,
2226-
name, name, default, doc
2223+
"#
22272224
)
22282225
} else {
22292226
format!("[[{name}]]{name} (default: `{default}`)::\n+\n--\n{doc}--\n")

crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ fn rustc_code_description(code: Option<&str>) -> Option<lsp_types::CodeDescripti
502502
fn clippy_code_description(code: Option<&str>) -> Option<lsp_types::CodeDescription> {
503503
code.and_then(|code| {
504504
lsp_types::Url::parse(&format!(
505-
"https://rust-lang.github.io/rust-clippy/master/index.html#{}",
506-
code
505+
"https://rust-lang.github.io/rust-clippy/master/index.html#{code}"
507506
))
508507
.ok()
509508
.map(|href| lsp_types::CodeDescription { href })

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,7 @@ impl GlobalState {
414414
let loop_duration = loop_start.elapsed();
415415
if loop_duration > Duration::from_millis(100) && was_quiescent {
416416
tracing::warn!("overly long loop turn: {:?}", loop_duration);
417-
self.poke_rust_analyzer_developer(format!(
418-
"overly long loop turn: {:?}",
419-
loop_duration
420-
));
417+
self.poke_rust_analyzer_developer(format!("overly long loop turn: {loop_duration:?}"));
421418
}
422419
Ok(())
423420
}

crates/rust-analyzer/tests/slow-tests/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,13 @@ fn test_missing_module_code_action_in_json_project() {
528528
let code = format!(
529529
r#"
530530
//- /rust-project.json
531-
{PROJECT}
531+
{project}
532532
533533
//- /src/lib.rs
534534
mod bar;
535535
536536
fn main() {{}}
537537
"#,
538-
PROJECT = project,
539538
);
540539

541540
let server =
@@ -605,13 +604,12 @@ name = "foo"
605604
version = "0.0.0"
606605
607606
//- /src/lib.rs
608-
{}
607+
{librs}
609608
610-
{}
609+
{libs}
611610
612611
fn main() {{}}
613-
"#,
614-
librs, libs
612+
"#
615613
))
616614
.with_config(serde_json::json!({
617615
"cargo": { "sysroot": "discover" }

crates/rust-analyzer/tests/slow-tests/tidy.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ fn check_lsp_extensions_docs() {
5656
"
5757
lsp_ext.rs was changed without touching lsp-extensions.md.
5858
59-
Expected hash: {:x}
60-
Actual hash: {:x}
59+
Expected hash: {expected_hash:x}
60+
Actual hash: {actual_hash:x}
6161
6262
Please adjust docs/dev/lsp-extensions.md.
63-
",
64-
expected_hash, actual_hash
63+
"
6564
)
6665
}
6766
}

crates/sourcegen/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ impl CommentBlock {
6565
let first = block.contents.remove(0);
6666
first.strip_prefix(&tag).map(|id| {
6767
if block.is_doc {
68-
panic!(
69-
"Use plain (non-doc) comments with tags like {}:\n {}",
70-
tag, first
71-
);
68+
panic!("Use plain (non-doc) comments with tags like {tag}:\n {first}");
7269
}
7370

7471
block.id = id.trim().to_string();

crates/syntax/src/algo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,7 @@ fn main() {
646646
.format_with("\n", |v, f| f(&format!("Line {}: {}", line_number(v), &fmt_syntax(v))));
647647

648648
let actual = format!(
649-
"insertions:\n\n{}\n\nreplacements:\n\n{}\n\ndeletions:\n\n{}\n",
650-
insertions, replacements, deletions
649+
"insertions:\n\n{insertions}\n\nreplacements:\n\n{replacements}\n\ndeletions:\n\n{deletions}\n"
651650
);
652651
expected_diff.assert_eq(&actual);
653652

crates/test-utils/src/fixture.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,9 @@ impl Fixture {
135135
if line.contains("//-") {
136136
assert!(
137137
line.starts_with("//-"),
138-
"Metadata line {} has invalid indentation. \
138+
"Metadata line {ix} has invalid indentation. \
139139
All metadata lines need to have the same indentation.\n\
140-
The offending line: {:?}",
141-
ix,
142-
line
140+
The offending line: {line:?}"
143141
);
144142
}
145143

@@ -222,9 +220,7 @@ impl Fixture {
222220
for prelude_dep in extern_prelude.iter().flatten() {
223221
assert!(
224222
deps.contains(prelude_dep),
225-
"extern-prelude {:?} must be a subset of deps {:?}",
226-
extern_prelude,
227-
deps
223+
"extern-prelude {extern_prelude:?} must be a subset of deps {deps:?}"
228224
);
229225
}
230226

@@ -348,11 +344,7 @@ impl MiniCore {
348344

349345
let mut keep = true;
350346
for &region in &active_regions {
351-
assert!(
352-
!region.starts_with(' '),
353-
"region marker starts with a space: {:?}",
354-
region
355-
);
347+
assert!(!region.starts_with(' '), "region marker starts with a space: {region:?}");
356348
self.assert_valid_flag(region);
357349
seen_regions.push(region);
358350
keep &= self.has_flag(region);

0 commit comments

Comments
 (0)