Skip to content

Commit fd7a159

Browse files
committed
Fix uninlined_format_args for some compiler crates
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).
1 parent 1d284af commit fd7a159

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

+3-3
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

+2-2
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

+1-1
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

+2-2
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

+7-7
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

+1-2
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

+3-3
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

+2-2
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

+1-1
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

+4-4
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
}

compiler/rustc_ast_pretty/src/pprust/state.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,23 @@ fn doc_comment_to_string(
191191
data: Symbol,
192192
) -> String {
193193
match (comment_kind, attr_style) {
194-
(CommentKind::Line, ast::AttrStyle::Outer) => format!("///{}", data),
195-
(CommentKind::Line, ast::AttrStyle::Inner) => format!("//!{}", data),
196-
(CommentKind::Block, ast::AttrStyle::Outer) => format!("/**{}*/", data),
197-
(CommentKind::Block, ast::AttrStyle::Inner) => format!("/*!{}*/", data),
194+
(CommentKind::Line, ast::AttrStyle::Outer) => format!("///{data}"),
195+
(CommentKind::Line, ast::AttrStyle::Inner) => format!("//!{data}"),
196+
(CommentKind::Block, ast::AttrStyle::Outer) => format!("/**{data}*/"),
197+
(CommentKind::Block, ast::AttrStyle::Inner) => format!("/*!{data}*/"),
198198
}
199199
}
200200

201201
pub fn literal_to_string(lit: token::Lit) -> String {
202202
let token::Lit { kind, symbol, suffix } = lit;
203203
let mut out = match kind {
204-
token::Byte => format!("b'{}'", symbol),
205-
token::Char => format!("'{}'", symbol),
206-
token::Str => format!("\"{}\"", symbol),
204+
token::Byte => format!("b'{symbol}'"),
205+
token::Char => format!("'{symbol}'"),
206+
token::Str => format!("\"{symbol}\""),
207207
token::StrRaw(n) => {
208208
format!("r{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = symbol)
209209
}
210-
token::ByteStr => format!("b\"{}\"", symbol),
210+
token::ByteStr => format!("b\"{symbol}\""),
211211
token::ByteStrRaw(n) => {
212212
format!("br{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = symbol)
213213
}

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ impl<'a> State<'a> {
411411
ast::VisibilityKind::Restricted { path, shorthand, .. } => {
412412
let path = Self::to_string(|s| s.print_path(path, false, 0));
413413
if *shorthand && (path == "crate" || path == "self" || path == "super") {
414-
self.word_nbsp(format!("pub({})", path))
414+
self.word_nbsp(format!("pub({path})"))
415415
} else {
416-
self.word_nbsp(format!("pub(in {})", path))
416+
self.word_nbsp(format!("pub(in {path})"))
417417
}
418418
}
419419
ast::VisibilityKind::Inherited => {}

compiler/rustc_attr/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ fn try_gate_cfg(name: Symbol, span: Span, sess: &ParseSess, features: Option<&Fe
619619
fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &Features) {
620620
let (cfg, feature, has_feature) = gated_cfg;
621621
if !has_feature(features) && !cfg_span.allows_unstable(*feature) {
622-
let explain = format!("`cfg({})` is experimental and subject to change", cfg);
622+
let explain = format!("`cfg({cfg})` is experimental and subject to change");
623623
feature_err(sess, *feature, cfg_span, &explain).emit();
624624
}
625625
}
@@ -975,7 +975,7 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
975975
}
976976

977977
pub fn parse_repr_attr(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
978-
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {:?}", attr);
978+
assert!(attr.has_name(sym::repr), "expected `#[repr(..)]`, found: {attr:?}");
979979
use ReprAttr::*;
980980
let mut acc = Vec::new();
981981
let diagnostic = &sess.parse_sess.span_diagnostic;

compiler/rustc_attr/src/session_diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) struct UnknownMetaItem<'a> {
5151
// Manual implementation to be able to format `expected` items correctly.
5252
impl<'a> IntoDiagnostic<'a> for UnknownMetaItem<'_> {
5353
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, ErrorGuaranteed> {
54-
let expected = self.expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
54+
let expected = self.expected.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>();
5555
let mut diag = handler.struct_span_err_with_code(
5656
self.span,
5757
fluent::attr_unknown_meta_item,

compiler/rustc_data_structures/src/graph/dominators/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,12 @@ impl<Node: Idx> Dominators<Node> {
277277
}
278278

279279
pub fn immediate_dominator(&self, node: Node) -> Node {
280-
assert!(self.is_reachable(node), "node {:?} is not reachable", node);
280+
assert!(self.is_reachable(node), "node {node:?} is not reachable");
281281
self.immediate_dominators[node].unwrap()
282282
}
283283

284284
pub fn dominators(&self, node: Node) -> Iter<'_, Node> {
285-
assert!(self.is_reachable(node), "node {:?} is not reachable", node);
285+
assert!(self.is_reachable(node), "node {node:?} is not reachable");
286286
Iter { dominators: self, node: Some(node) }
287287
}
288288

compiler/rustc_data_structures/src/graph/scc/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,9 @@ where
233233
.map(G::Node::new)
234234
.map(|node| match this.start_walk_from(node) {
235235
WalkReturn::Complete { scc_index } => scc_index,
236-
WalkReturn::Cycle { min_depth } => panic!(
237-
"`start_walk_node({:?})` returned cycle with depth {:?}",
238-
node, min_depth
239-
),
236+
WalkReturn::Cycle { min_depth } => {
237+
panic!("`start_walk_node({node:?})` returned cycle with depth {min_depth:?}")
238+
}
240239
})
241240
.collect();
242241

@@ -272,8 +271,7 @@ where
272271
NodeState::NotVisited => return None,
273272

274273
NodeState::InCycleWith { parent } => panic!(
275-
"`find_state` returned `InCycleWith({:?})`, which ought to be impossible",
276-
parent
274+
"`find_state` returned `InCycleWith({parent:?})`, which ought to be impossible"
277275
),
278276
})
279277
}
@@ -369,7 +367,7 @@ where
369367
previous_node = previous;
370368
}
371369
// Only InCycleWith nodes were added to the reverse linked list.
372-
other => panic!("Invalid previous link while compressing cycle: {:?}", other),
370+
other => panic!("Invalid previous link while compressing cycle: {other:?}"),
373371
}
374372

375373
debug!("find_state: parent_state = {:?}", node_state);
@@ -394,7 +392,7 @@ where
394392
// NotVisited can not be part of a cycle since it should
395393
// have instead gotten explored.
396394
NodeState::NotVisited | NodeState::InCycleWith { .. } => {
397-
panic!("invalid parent state: {:?}", node_state)
395+
panic!("invalid parent state: {node_state:?}")
398396
}
399397
}
400398
}

compiler/rustc_data_structures/src/obligation_forest/graphviz.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<O: ForestObligation> ObligationForest<O> {
3030

3131
let counter = COUNTER.fetch_add(1, Ordering::AcqRel);
3232

33-
let file_path = dir.as_ref().join(format!("{:010}_{}.gv", counter, description));
33+
let file_path = dir.as_ref().join(format!("{counter:010}_{description}.gv"));
3434

3535
let mut gv_file = BufWriter::new(File::create(file_path).unwrap());
3636

@@ -47,7 +47,7 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest<O>
4747
}
4848

4949
fn node_id(&self, index: &Self::Node) -> dot::Id<'_> {
50-
dot::Id::new(format!("obligation_{}", index)).unwrap()
50+
dot::Id::new(format!("obligation_{index}")).unwrap()
5151
}
5252

5353
fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> {

compiler/rustc_data_structures/src/profiling.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl SelfProfiler {
545545
// length can behave as a source of entropy for heap addresses, when
546546
// ASLR is disabled and the heap is otherwise determinic.
547547
let pid: u32 = process::id();
548-
let filename = format!("{}-{:07}.rustc_profile", crate_name, pid);
548+
let filename = format!("{crate_name}-{pid:07}.rustc_profile");
549549
let path = output_directory.join(&filename);
550550
let profiler =
551551
Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?;

compiler/rustc_data_structures/src/small_c_str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl SmallCStr {
3030
SmallVec::from_vec(data)
3131
};
3232
if let Err(e) = ffi::CStr::from_bytes_with_nul(&data) {
33-
panic!("The string \"{}\" cannot be converted into a CStr: {}", s, e);
33+
panic!("The string \"{s}\" cannot be converted into a CStr: {e}");
3434
}
3535
SmallCStr { data }
3636
}
@@ -39,7 +39,7 @@ impl SmallCStr {
3939
pub fn new_with_nul(s: &str) -> SmallCStr {
4040
let b = s.as_bytes();
4141
if let Err(e) = ffi::CStr::from_bytes_with_nul(b) {
42-
panic!("The string \"{}\" cannot be converted into a CStr: {}", s, e);
42+
panic!("The string \"{s}\" cannot be converted into a CStr: {e}");
4343
}
4444
SmallCStr { data: SmallVec::from_slice(s.as_bytes()) }
4545
}
@@ -74,7 +74,7 @@ impl<'a> FromIterator<&'a str> for SmallCStr {
7474
iter.into_iter().flat_map(|s| s.as_bytes()).copied().collect::<SmallVec<_>>();
7575
data.push(0);
7676
if let Err(e) = ffi::CStr::from_bytes_with_nul(&data) {
77-
panic!("The iterator {:?} cannot be converted into a CStr: {}", data, e);
77+
panic!("The iterator {data:?} cannot be converted into a CStr: {e}");
7878
}
7979
Self { data }
8080
}

compiler/rustc_data_structures/src/vec_map.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ where
7171
// This should return just one element, otherwise it's a bug
7272
assert!(
7373
filter.next().is_none(),
74-
"Collection {:#?} should have just one matching element",
75-
self
74+
"Collection {self:#?} should have just one matching element"
7675
);
7776
Some(value)
7877
}

0 commit comments

Comments
 (0)