Skip to content

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
}

0 commit comments

Comments
 (0)