Skip to content
/ rust Public
forked from rust-lang/rust

Commit 89acdae

Browse files
committed
Auto merge of rust-lang#114250 - matthiaskrgr:rollup-0r0dhrr, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#110056 (Fix the example in document for WaitTimeoutResult::timed_out) - rust-lang#112655 (Mark `map_or` as `#[must_use]`) - rust-lang#114018 (Make `--error-format human-annotate-rs` handle multiple files) - rust-lang#114068 (inline format!() args up to and including rustc_middle (2)) - rust-lang#114223 (Documentation: Fix Stilted Language in Vec->Indexing) - rust-lang#114227 (Add tidy check for stray rustfix files) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 483ef5f + b9f17f1 commit 89acdae

File tree

101 files changed

+439
-466
lines changed

Some content is hidden

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

101 files changed

+439
-466
lines changed

compiler/rustc/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn set_windows_exe_options() {
1818
let mut manifest = env::current_dir().unwrap();
1919
manifest.push(WINDOWS_MANIFEST_FILE);
2020

21-
println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
21+
println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");
2222
// Embed the Windows application manifest file.
2323
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");
2424
println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());

compiler/rustc_abi/src/layout.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ pub trait LayoutCalculator {
260260
}
261261
_ => assert!(
262262
start == Bound::Unbounded && end == Bound::Unbounded,
263-
"nonscalar layout for layout_scalar_valid_range type: {:#?}",
264-
st,
263+
"nonscalar layout for layout_scalar_valid_range type: {st:#?}",
265264
),
266265
}
267266

@@ -463,7 +462,7 @@ pub trait LayoutCalculator {
463462
min = 0;
464463
max = 0;
465464
}
466-
assert!(min <= max, "discriminant range is {}...{}", min, max);
465+
assert!(min <= max, "discriminant range is {min}...{max}");
467466
let (min_ity, signed) = discr_range_of_repr(min, max); //Integer::repr_discr(tcx, ty, &repr, min, max);
468467

469468
let mut align = dl.aggregate_align;
@@ -537,8 +536,7 @@ pub trait LayoutCalculator {
537536
// space necessary to represent would have to be discarded (or layout is wrong
538537
// on thinking it needs 16 bits)
539538
panic!(
540-
"layout decided on a larger discriminant type ({:?}) than typeck ({:?})",
541-
min_ity, typeck_ity
539+
"layout decided on a larger discriminant type ({min_ity:?}) than typeck ({typeck_ity:?})"
542540
);
543541
// However, it is fine to make discr type however large (as an optimisation)
544542
// after this point – we’ll just truncate the value we load in codegen.

compiler/rustc_abi/src/lib.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl TargetDataLayout {
332332
16 => 1 << 15,
333333
32 => 1 << 31,
334334
64 => 1 << 47,
335-
bits => panic!("obj_size_bound: unknown pointer bit size {}", bits),
335+
bits => panic!("obj_size_bound: unknown pointer bit size {bits}"),
336336
}
337337
}
338338

@@ -342,7 +342,7 @@ impl TargetDataLayout {
342342
16 => I16,
343343
32 => I32,
344344
64 => I64,
345-
bits => panic!("ptr_sized_integer: unknown pointer bit size {}", bits),
345+
bits => panic!("ptr_sized_integer: unknown pointer bit size {bits}"),
346346
}
347347
}
348348

@@ -399,7 +399,7 @@ impl FromStr for Endian {
399399
match s {
400400
"little" => Ok(Self::Little),
401401
"big" => Ok(Self::Big),
402-
_ => Err(format!(r#"unknown endian: "{}""#, s)),
402+
_ => Err(format!(r#"unknown endian: "{s}""#)),
403403
}
404404
}
405405
}
@@ -456,7 +456,7 @@ impl Size {
456456
pub fn bits(self) -> u64 {
457457
#[cold]
458458
fn overflow(bytes: u64) -> ! {
459-
panic!("Size::bits: {} bytes in bits doesn't fit in u64", bytes)
459+
panic!("Size::bits: {bytes} bytes in bits doesn't fit in u64")
460460
}
461461

462462
self.bytes().checked_mul(8).unwrap_or_else(|| overflow(self.bytes()))
@@ -1179,17 +1179,12 @@ impl FieldsShape {
11791179
unreachable!("FieldsShape::offset: `Primitive`s have no fields")
11801180
}
11811181
FieldsShape::Union(count) => {
1182-
assert!(
1183-
i < count.get(),
1184-
"tried to access field {} of union with {} fields",
1185-
i,
1186-
count
1187-
);
1182+
assert!(i < count.get(), "tried to access field {i} of union with {count} fields");
11881183
Size::ZERO
11891184
}
11901185
FieldsShape::Array { stride, count } => {
11911186
let i = u64::try_from(i).unwrap();
1192-
assert!(i < count, "tried to access field {} of array with {} fields", i, count);
1187+
assert!(i < count, "tried to access field {i} of array with {count} fields");
11931188
stride * i
11941189
}
11951190
FieldsShape::Arbitrary { ref offsets, .. } => offsets[FieldIdx::from_usize(i)],
@@ -1294,7 +1289,7 @@ impl Abi {
12941289
Primitive::Int(_, signed) => signed,
12951290
_ => false,
12961291
},
1297-
_ => panic!("`is_signed` on non-scalar ABI {:?}", self),
1292+
_ => panic!("`is_signed` on non-scalar ABI {self:?}"),
12981293
}
12991294
}
13001295

compiler/rustc_ast_passes/src/ast_validation.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn validate_generic_param_order(
659659
GenericParamKind::Type { .. } => (ParamKindOrd::TypeOrConst, ident.to_string()),
660660
GenericParamKind::Const { ty, .. } => {
661661
let ty = pprust::ty_to_string(ty);
662-
(ParamKindOrd::TypeOrConst, format!("const {}: {}", ident, ty))
662+
(ParamKindOrd::TypeOrConst, format!("const {ident}: {ty}"))
663663
}
664664
};
665665
param_idents.push((kind, ord_kind, bounds, idx, ident));
@@ -1463,15 +1463,12 @@ fn deny_equality_constraints(
14631463
let Some(arg) = args.args.last() else {
14641464
continue;
14651465
};
1466-
(
1467-
format!(", {} = {}", assoc, ty),
1468-
arg.span().shrink_to_hi(),
1469-
)
1466+
(format!(", {assoc} = {ty}"), arg.span().shrink_to_hi())
14701467
}
14711468
_ => continue,
14721469
},
14731470
None => (
1474-
format!("<{} = {}>", assoc, ty),
1471+
format!("<{assoc} = {ty}>"),
14751472
trait_segment.span().shrink_to_hi(),
14761473
),
14771474
};

compiler/rustc_builtin_macros/src/asm.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
575575
|| named_pos.contains_key(&idx)
576576
|| args.reg_args.contains(idx)
577577
{
578-
let msg = format!("invalid reference to argument at index {}", idx);
578+
let msg = format!("invalid reference to argument at index {idx}");
579579
let mut err = ecx.struct_span_err(span, msg);
580580
err.span_label(span, "from here");
581581

@@ -588,9 +588,9 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
588588
""
589589
};
590590
let msg = match positional_args {
591-
0 => format!("no {}arguments were given", positional),
592-
1 => format!("there is 1 {}argument", positional),
593-
x => format!("there are {} {}arguments", x, positional),
591+
0 => format!("no {positional}arguments were given"),
592+
1 => format!("there is 1 {positional}argument"),
593+
x => format!("there are {x} {positional}arguments"),
594594
};
595595
err.note(msg);
596596

@@ -624,7 +624,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
624624
match args.named_args.get(&Symbol::intern(name)) {
625625
Some(&idx) => Some(idx),
626626
None => {
627-
let msg = format!("there is no argument named `{}`", name);
627+
let msg = format!("there is no argument named `{name}`");
628628
let span = arg.position_span;
629629
ecx.struct_span_err(
630630
template_span
@@ -697,8 +697,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
697697
err.span_label(sp, msg);
698698
err.help(format!(
699699
"if this argument is intentionally unused, \
700-
consider using it in an asm comment: `\"/*{} */\"`",
701-
help_str
700+
consider using it in an asm comment: `\"/*{help_str} */\"`"
702701
));
703702
err.emit();
704703
}
@@ -712,8 +711,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::Inl
712711
}
713712
err.help(format!(
714713
"if these arguments are intentionally unused, \
715-
consider using them in an asm comment: `\"/*{} */\"`",
716-
help_str
714+
consider using them in an asm comment: `\"/*{help_str} */\"`"
717715
));
718716
err.emit();
719717
}

compiler/rustc_builtin_macros/src/deriving/clone.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn cs_clone_simple(
144144
}
145145
_ => cx.span_bug(
146146
trait_span,
147-
format!("unexpected substructure in simple `derive({})`", name),
147+
format!("unexpected substructure in simple `derive({name})`"),
148148
),
149149
}
150150
}
@@ -178,10 +178,10 @@ fn cs_clone(
178178
vdata = &variant.data;
179179
}
180180
EnumTag(..) | AllFieldlessEnum(..) => {
181-
cx.span_bug(trait_span, format!("enum tags in `derive({})`", name,))
181+
cx.span_bug(trait_span, format!("enum tags in `derive({name})`",))
182182
}
183183
StaticEnum(..) | StaticStruct(..) => {
184-
cx.span_bug(trait_span, format!("associated function in `derive({})`", name))
184+
cx.span_bug(trait_span, format!("associated function in `derive({name})`"))
185185
}
186186
}
187187

@@ -193,7 +193,7 @@ fn cs_clone(
193193
let Some(ident) = field.name else {
194194
cx.span_bug(
195195
trait_span,
196-
format!("unnamed field in normal struct in `derive({})`", name,),
196+
format!("unnamed field in normal struct in `derive({name})`",),
197197
);
198198
};
199199
let call = subcall(cx, field);

compiler/rustc_builtin_macros/src/deriving/decodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ where
204204
let fields = fields
205205
.iter()
206206
.enumerate()
207-
.map(|(i, &span)| getarg(cx, span, Symbol::intern(&format!("_field{}", i)), i))
207+
.map(|(i, &span)| getarg(cx, span, Symbol::intern(&format!("_field{i}")), i))
208208
.collect();
209209

210210
cx.expr_call(trait_span, path_expr, fields)

compiler/rustc_builtin_macros/src/deriving/encodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn encodable_substructure(
173173
for (i, &FieldInfo { name, ref self_expr, span, .. }) in fields.iter().enumerate() {
174174
let name = match name {
175175
Some(id) => id.name,
176-
None => Symbol::intern(&format!("_field{}", i)),
176+
None => Symbol::intern(&format!("_field{i}")),
177177
};
178178
let self_ref = cx.expr_addr_of(span, self_expr.clone());
179179
let enc =

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ impl<'a> MethodDef<'a> {
11661166
.iter()
11671167
.enumerate()
11681168
.skip(1)
1169-
.map(|(arg_count, _selflike_arg)| format!("__arg{}", arg_count)),
1169+
.map(|(arg_count, _selflike_arg)| format!("__arg{arg_count}")),
11701170
)
11711171
.collect::<Vec<String>>();
11721172

@@ -1181,7 +1181,7 @@ impl<'a> MethodDef<'a> {
11811181
let get_tag_pieces = |cx: &ExtCtxt<'_>| {
11821182
let tag_idents: Vec<_> = prefixes
11831183
.iter()
1184-
.map(|name| Ident::from_str_and_span(&format!("{}_tag", name), span))
1184+
.map(|name| Ident::from_str_and_span(&format!("{name}_tag"), span))
11851185
.collect();
11861186

11871187
let mut tag_exprs: Vec<_> = tag_idents
@@ -1521,7 +1521,7 @@ impl<'a> TraitDef<'a> {
15211521
}
15221522

15231523
fn mk_pattern_ident(&self, prefix: &str, i: usize) -> Ident {
1524-
Ident::from_str_and_span(&format!("{}_{}", prefix, i), self.span)
1524+
Ident::from_str_and_span(&format!("{prefix}_{i}"), self.span)
15251525
}
15261526

15271527
fn create_struct_pattern_fields(
@@ -1602,8 +1602,7 @@ impl<'a> TraitDef<'a> {
16021602
sp,
16031603
ast::CRATE_NODE_ID,
16041604
format!(
1605-
"{} slice in a packed struct that derives a built-in trait",
1606-
ty
1605+
"{ty} slice in a packed struct that derives a built-in trait"
16071606
),
16081607
rustc_lint_defs::BuiltinLintDiagnostics::ByteSliceInPackedStructWithDerive
16091608
);

compiler/rustc_builtin_macros/src/format.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn make_format_args(
179179
err.span_suggestion(
180180
unexpanded_fmt_span.shrink_to_lo(),
181181
"you might be missing a string literal to format with",
182-
format!("\"{}\", ", sugg_fmt),
182+
format!("\"{sugg_fmt}\", "),
183183
Applicability::MaybeIncorrect,
184184
);
185185
}
@@ -668,7 +668,7 @@ fn report_invalid_references(
668668
let num_args_desc = match args.explicit_args().len() {
669669
0 => "no arguments were given".to_string(),
670670
1 => "there is 1 argument".to_string(),
671-
n => format!("there are {} arguments", n),
671+
n => format!("there are {n} arguments"),
672672
};
673673

674674
let mut e;
@@ -780,7 +780,7 @@ fn report_invalid_references(
780780
if num_placeholders == 1 {
781781
"is 1 argument".to_string()
782782
} else {
783-
format!("are {} arguments", num_placeholders)
783+
format!("are {num_placeholders} arguments")
784784
},
785785
),
786786
);
@@ -811,7 +811,7 @@ fn report_invalid_references(
811811
};
812812
e = ecx.struct_span_err(
813813
span,
814-
format!("invalid reference to positional {} ({})", arg_list, num_args_desc),
814+
format!("invalid reference to positional {arg_list} ({num_args_desc})"),
815815
);
816816
e.note("positional arguments are zero-based");
817817
}

compiler/rustc_builtin_macros/src/format_foreign.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ pub(crate) mod printf {
8686
'-' => c_left = true,
8787
'+' => c_plus = true,
8888
_ => {
89-
return Err(Some(format!(
90-
"the flag `{}` is unknown or unsupported",
91-
c
92-
)));
89+
return Err(Some(format!("the flag `{c}` is unknown or unsupported")));
9390
}
9491
}
9592
}
@@ -268,21 +265,21 @@ pub(crate) mod printf {
268265
impl Num {
269266
fn from_str(s: &str, arg: Option<&str>) -> Self {
270267
if let Some(arg) = arg {
271-
Num::Arg(arg.parse().unwrap_or_else(|_| panic!("invalid format arg `{:?}`", arg)))
268+
Num::Arg(arg.parse().unwrap_or_else(|_| panic!("invalid format arg `{arg:?}`")))
272269
} else if s == "*" {
273270
Num::Next
274271
} else {
275-
Num::Num(s.parse().unwrap_or_else(|_| panic!("invalid format num `{:?}`", s)))
272+
Num::Num(s.parse().unwrap_or_else(|_| panic!("invalid format num `{s:?}`")))
276273
}
277274
}
278275

279276
fn translate(&self, s: &mut String) -> std::fmt::Result {
280277
use std::fmt::Write;
281278
match *self {
282-
Num::Num(n) => write!(s, "{}", n),
279+
Num::Num(n) => write!(s, "{n}"),
283280
Num::Arg(n) => {
284281
let n = n.checked_sub(1).ok_or(std::fmt::Error)?;
285-
write!(s, "{}$", n)
282+
write!(s, "{n}$")
286283
}
287284
Num::Next => write!(s, "*"),
288285
}
@@ -626,8 +623,8 @@ pub mod shell {
626623
impl Substitution<'_> {
627624
pub fn as_str(&self) -> String {
628625
match self {
629-
Substitution::Ordinal(n, _) => format!("${}", n),
630-
Substitution::Name(n, _) => format!("${}", n),
626+
Substitution::Ordinal(n, _) => format!("${n}"),
627+
Substitution::Name(n, _) => format!("${n}"),
631628
Substitution::Escape(_) => "$$".into(),
632629
}
633630
}

compiler/rustc_builtin_macros/src/global_allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl AllocFnFactory<'_, '_> {
7272
let mut abi_args = ThinVec::new();
7373
let mut i = 0;
7474
let mut mk = || {
75-
let name = Ident::from_str_and_span(&format!("arg{}", i), self.span);
75+
let name = Ident::from_str_and_span(&format!("arg{i}"), self.span);
7676
i += 1;
7777
name
7878
};

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
179179
== prev_item.path.segments[0].ident.name
180180
{
181181
format!(
182-
"only one `#[{}]` attribute is allowed on any given function",
183-
path_str,
182+
"only one `#[{path_str}]` attribute is allowed on any given function",
184183
)
185184
} else {
186185
format!(

compiler/rustc_builtin_macros/src/source_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn expand_include<'cx>(
149149
Ok(None) => {
150150
if self.p.token != token::Eof {
151151
let token = pprust::token_to_string(&self.p.token);
152-
let msg = format!("expected item, found `{}`", token);
152+
let msg = format!("expected item, found `{token}`");
153153
self.p.struct_span_err(self.p.token.span, msg).emit();
154154
}
155155

0 commit comments

Comments
 (0)