Skip to content

Commit 0853d96

Browse files
committed
Auto merge of #105890 - Nilstrieb:inline-fmt-part-1, r=jackh726
Fix `uninlined_format_args` in compiler crates with the diagnostic migration completed Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem). Some of them have been reviewed by myself and they were all correct (though I still recommend going over all of them again for review).
2 parents b85f57d + fd7a159 commit 0853d96

File tree

91 files changed

+287
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+287
-329
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,10 +2170,10 @@ impl fmt::Display for InlineAsmTemplatePiece {
21702170
Ok(())
21712171
}
21722172
Self::Placeholder { operand_idx, modifier: Some(modifier), .. } => {
2173-
write!(f, "{{{}:{}}}", operand_idx, modifier)
2173+
write!(f, "{{{operand_idx}:{modifier}}}")
21742174
}
21752175
Self::Placeholder { operand_idx, modifier: None, .. } => {
2176-
write!(f, "{{{}}}", operand_idx)
2176+
write!(f, "{{{operand_idx}}}")
21772177
}
21782178
}
21792179
}
@@ -2185,7 +2185,7 @@ impl InlineAsmTemplatePiece {
21852185
use fmt::Write;
21862186
let mut out = String::new();
21872187
for p in s.iter() {
2188-
let _ = write!(out, "{}", p);
2188+
let _ = write!(out, "{p}");
21892189
}
21902190
out
21912191
}

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ impl HasTokens for Attribute {
214214
match &self.kind {
215215
AttrKind::Normal(normal) => normal.tokens.as_ref(),
216216
kind @ AttrKind::DocComment(..) => {
217-
panic!("Called tokens on doc comment attr {:?}", kind)
217+
panic!("Called tokens on doc comment attr {kind:?}")
218218
}
219219
}
220220
}
221221
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
222222
Some(match &mut self.kind {
223223
AttrKind::Normal(normal) => &mut normal.tokens,
224224
kind @ AttrKind::DocComment(..) => {
225-
panic!("Called tokens_mut on doc comment attr {:?}", kind)
225+
panic!("Called tokens_mut on doc comment attr {kind:?}")
226226
}
227227
})
228228
}

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl Attribute {
310310
AttrKind::Normal(normal) => normal
311311
.tokens
312312
.as_ref()
313-
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
313+
.unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
314314
.to_attr_token_stream()
315315
.to_tokenstream(),
316316
&AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub enum AllocatorKind {
99
impl AllocatorKind {
1010
pub fn fn_name(&self, base: Symbol) -> String {
1111
match *self {
12-
AllocatorKind::Global => format!("__rg_{}", base),
13-
AllocatorKind::Default => format!("__rdl_{}", base),
12+
AllocatorKind::Global => format!("__rg_{base}"),
13+
AllocatorKind::Default => format!("__rdl_{base}"),
1414
}
1515
}
1616
}

compiler/rustc_ast/src/token.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,27 @@ impl fmt::Display for Lit {
125125
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126126
let Lit { kind, symbol, suffix } = *self;
127127
match kind {
128-
Byte => write!(f, "b'{}'", symbol)?,
129-
Char => write!(f, "'{}'", symbol)?,
130-
Str => write!(f, "\"{}\"", symbol)?,
128+
Byte => write!(f, "b'{symbol}'")?,
129+
Char => write!(f, "'{symbol}'")?,
130+
Str => write!(f, "\"{symbol}\"")?,
131131
StrRaw(n) => write!(
132132
f,
133133
"r{delim}\"{string}\"{delim}",
134134
delim = "#".repeat(n as usize),
135135
string = symbol
136136
)?,
137-
ByteStr => write!(f, "b\"{}\"", symbol)?,
137+
ByteStr => write!(f, "b\"{symbol}\"")?,
138138
ByteStrRaw(n) => write!(
139139
f,
140140
"br{delim}\"{string}\"{delim}",
141141
delim = "#".repeat(n as usize),
142142
string = symbol
143143
)?,
144-
Integer | Float | Bool | Err => write!(f, "{}", symbol)?,
144+
Integer | Float | Bool | Err => write!(f, "{symbol}")?,
145145
}
146146

147147
if let Some(suffix) = suffix {
148-
write!(f, "{}", suffix)?;
148+
write!(f, "{suffix}")?;
149149
}
150150

151151
Ok(())
@@ -756,7 +756,7 @@ impl Token {
756756
_ => return None,
757757
},
758758
SingleQuote => match joint.kind {
759-
Ident(name, false) => Lifetime(Symbol::intern(&format!("'{}", name))),
759+
Ident(name, false) => Lifetime(Symbol::intern(&format!("'{name}"))),
760760
_ => return None,
761761
},
762762

compiler/rustc_ast/src/tokenstream.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ impl AttrTokenStream {
258258

259259
assert!(
260260
found,
261-
"Failed to find trailing delimited group in: {:?}",
262-
target_tokens
261+
"Failed to find trailing delimited group in: {target_tokens:?}"
263262
);
264263
}
265264
let mut flat: SmallVec<[_; 1]> = SmallVec::new();

compiler/rustc_ast/src/util/literal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl fmt::Display for LitKind {
168168
match *self {
169169
LitKind::Byte(b) => {
170170
let b: String = ascii::escape_default(b).map(Into::<char>::into).collect();
171-
write!(f, "b'{}'", b)?;
171+
write!(f, "b'{b}'")?;
172172
}
173173
LitKind::Char(ch) => write!(f, "'{}'", escape_char_symbol(ch))?,
174174
LitKind::Str(sym, StrStyle::Cooked) => write!(f, "\"{}\"", escape_string_symbol(sym))?,
@@ -192,15 +192,15 @@ impl fmt::Display for LitKind {
192192
)?;
193193
}
194194
LitKind::Int(n, ty) => {
195-
write!(f, "{}", n)?;
195+
write!(f, "{n}")?;
196196
match ty {
197197
ast::LitIntType::Unsigned(ty) => write!(f, "{}", ty.name())?,
198198
ast::LitIntType::Signed(ty) => write!(f, "{}", ty.name())?,
199199
ast::LitIntType::Unsuffixed => {}
200200
}
201201
}
202202
LitKind::Float(symbol, ty) => {
203-
write!(f, "{}", symbol)?;
203+
write!(f, "{symbol}")?;
204204
match ty {
205205
ast::LitFloatType::Suffixed(ty) => write!(f, "{}", ty.name())?,
206206
ast::LitFloatType::Unsuffixed => {}

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
104104
Err(supported_abis) => {
105105
let mut abis = format!("`{}`", supported_abis[0]);
106106
for m in &supported_abis[1..] {
107-
let _ = write!(abis, ", `{}`", m);
107+
let _ = write!(abis, ", `{m}`");
108108
}
109109
self.tcx.sess.emit_err(InvalidAbiClobberAbi {
110110
abi_span: *abi_span,
@@ -262,7 +262,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
262262
let sub = if !valid_modifiers.is_empty() {
263263
let mut mods = format!("`{}`", valid_modifiers[0]);
264264
for m in &valid_modifiers[1..] {
265-
let _ = write!(mods, ", `{}`", m);
265+
let _ = write!(mods, ", `{m}`");
266266
}
267267
InvalidAsmTemplateModifierRegClassSub::SupportModifier {
268268
class_name: class.name(),

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10511051
}
10521052
_ => {
10531053
// Replace the ident for bindings that aren't simple.
1054-
let name = format!("__arg{}", index);
1054+
let name = format!("__arg{index}");
10551055
let ident = Ident::from_str(&name);
10561056

10571057
(ident, false)

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl std::fmt::Display for ImplTraitPosition {
296296
ImplTraitPosition::ImplReturn => "`impl` method return",
297297
};
298298

299-
write!(f, "{}", name)
299+
write!(f, "{name}")
300300
}
301301
}
302302

@@ -503,7 +503,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
503503

504504
fn orig_local_def_id(&self, node: NodeId) -> LocalDefId {
505505
self.orig_opt_local_def_id(node)
506-
.unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
506+
.unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
507507
}
508508

509509
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
@@ -524,7 +524,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
524524
}
525525

526526
fn local_def_id(&self, node: NodeId) -> LocalDefId {
527-
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
527+
self.opt_local_def_id(node).unwrap_or_else(|| panic!("no entry for node id: `{node:?}`"))
528528
}
529529

530530
/// Get the previously recorded `to` local def id given the `from` local def id, obtained using
@@ -2197,7 +2197,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21972197
fn lower_trait_ref(&mut self, p: &TraitRef, itctx: &ImplTraitContext) -> hir::TraitRef<'hir> {
21982198
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
21992199
hir::QPath::Resolved(None, path) => path,
2200-
qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
2200+
qpath => panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
22012201
};
22022202
hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
22032203
}

0 commit comments

Comments
 (0)