Skip to content

File tree

273 files changed

+1218
-1473
lines changed

Some content is hidden

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

273 files changed

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

+6-11
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,12 +1179,7 @@ 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 } => {
@@ -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_apfloat/src/ieee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,9 @@ impl<S: Semantics> fmt::Display for IeeeFloat<S> {
570570

571571
// Exponent always at least two digits if we do not truncate zeros.
572572
if truncate_zero {
573-
write!(f, "{:+}", exp)?;
573+
write!(f, "{exp:+}")?;
574574
} else {
575-
write!(f, "{:+03}", exp)?;
575+
write!(f, "{exp:+03}")?;
576576
}
577577

578578
return Ok(());

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_borrowck/src/borrowck_errors.rs

+20-26
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
3737
desc,
3838
);
3939

40-
err.span_label(borrow_span, format!("{} is borrowed here", borrow_desc));
41-
err.span_label(span, format!("use of borrowed {}", borrow_desc));
40+
err.span_label(borrow_span, format!("{borrow_desc} is borrowed here"));
41+
err.span_label(span, format!("use of borrowed {borrow_desc}"));
4242
err
4343
}
4444

@@ -51,8 +51,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
5151
old_opt_via: &str,
5252
old_load_end_span: Option<Span>,
5353
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
54-
let via =
55-
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
54+
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
5655
let mut err = struct_span_err!(
5756
self,
5857
new_loan_span,
@@ -143,9 +142,9 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
143142
);
144143
err.span_label(
145144
new_loan_span,
146-
format!("{} construction occurs here{}", container_name, opt_via),
145+
format!("{container_name} construction occurs here{opt_via}"),
147146
);
148-
err.span_label(old_loan_span, format!("borrow occurs here{}", old_opt_via));
147+
err.span_label(old_loan_span, format!("borrow occurs here{old_opt_via}"));
149148
if let Some(previous_end_span) = previous_end_span {
150149
err.span_label(previous_end_span, "borrow ends here");
151150
}
@@ -173,13 +172,10 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
173172
opt_via,
174173
kind_new,
175174
);
176-
err.span_label(
177-
new_loan_span,
178-
format!("{}borrow occurs here{}", second_borrow_desc, opt_via),
179-
);
175+
err.span_label(new_loan_span, format!("{second_borrow_desc}borrow occurs here{opt_via}"));
180176
err.span_label(
181177
old_loan_span,
182-
format!("{} construction occurs here{}", container_name, old_opt_via),
178+
format!("{container_name} construction occurs here{old_opt_via}"),
183179
);
184180
if let Some(previous_end_span) = previous_end_span {
185181
err.span_label(previous_end_span, "borrow from closure ends here");
@@ -199,8 +195,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
199195
msg_old: &str,
200196
old_load_end_span: Option<Span>,
201197
) -> DiagnosticBuilder<'cx, ErrorGuaranteed> {
202-
let via =
203-
|msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {})", msg) };
198+
let via = |msg: &str| if msg.is_empty() { "".to_string() } else { format!(" (via {msg})") };
204199
let mut err = struct_span_err!(
205200
self,
206201
span,
@@ -216,22 +211,21 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
216211

217212
if msg_new == "" {
218213
// If `msg_new` is empty, then this isn't a borrow of a union field.
219-
err.span_label(span, format!("{} borrow occurs here", kind_new));
220-
err.span_label(old_span, format!("{} borrow occurs here", kind_old));
214+
err.span_label(span, format!("{kind_new} borrow occurs here"));
215+
err.span_label(old_span, format!("{kind_old} borrow occurs here"));
221216
} else {
222217
// If `msg_new` isn't empty, then this a borrow of a union field.
223218
err.span_label(
224219
span,
225220
format!(
226-
"{} borrow of {} -- which overlaps with {} -- occurs here",
227-
kind_new, msg_new, msg_old,
221+
"{kind_new} borrow of {msg_new} -- which overlaps with {msg_old} -- occurs here",
228222
),
229223
);
230224
err.span_label(old_span, format!("{} borrow occurs here{}", kind_old, via(msg_old)));
231225
}
232226

233227
if let Some(old_load_end_span) = old_load_end_span {
234-
err.span_label(old_load_end_span, format!("{} borrow ends here", kind_old));
228+
err.span_label(old_load_end_span, format!("{kind_old} borrow ends here"));
235229
}
236230
err
237231
}
@@ -250,8 +244,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
250244
desc,
251245
);
252246

253-
err.span_label(borrow_span, format!("{} is borrowed here", desc));
254-
err.span_label(span, format!("{} is assigned to here but it was already borrowed", desc));
247+
err.span_label(borrow_span, format!("{desc} is borrowed here"));
248+
err.span_label(span, format!("{desc} is assigned to here but it was already borrowed"));
255249
err
256250
}
257251

@@ -330,7 +324,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
330324
optional_adverb_for_moved: &str,
331325
moved_path: Option<String>,
332326
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
333-
let moved_path = moved_path.map(|mp| format!(": `{}`", mp)).unwrap_or_default();
327+
let moved_path = moved_path.map(|mp| format!(": `{mp}`")).unwrap_or_default();
334328

335329
struct_span_err!(
336330
self,
@@ -369,8 +363,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
369363
immutable_place,
370364
immutable_section,
371365
);
372-
err.span_label(mutate_span, format!("cannot {}", action));
373-
err.span_label(immutable_span, format!("value is immutable in {}", immutable_section));
366+
err.span_label(mutate_span, format!("cannot {action}"));
367+
err.span_label(immutable_span, format!("value is immutable in {immutable_section}"));
374368
err
375369
}
376370

@@ -428,7 +422,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
428422

429423
err.span_label(
430424
span,
431-
format!("{}s a {} data owned by the current function", return_kind, reference_desc),
425+
format!("{return_kind}s a {reference_desc} data owned by the current function"),
432426
);
433427

434428
err
@@ -449,8 +443,8 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
449443
"{closure_kind} may outlive the current {scope}, but it borrows {borrowed_path}, \
450444
which is owned by the current {scope}",
451445
);
452-
err.span_label(capture_span, format!("{} is borrowed here", borrowed_path))
453-
.span_label(closure_span, format!("may outlive borrowed value {}", borrowed_path));
446+
err.span_label(capture_span, format!("{borrowed_path} is borrowed here"))
447+
.span_label(closure_span, format!("may outlive borrowed value {borrowed_path}"));
454448
err
455449
}
456450

compiler/rustc_borrowck/src/dataflow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
360360
return;
361361
}
362362
let index = self.borrow_set.get_index_of(&location).unwrap_or_else(|| {
363-
panic!("could not find BorrowIndex for location {:?}", location);
363+
panic!("could not find BorrowIndex for location {location:?}");
364364
});
365365

366366
trans.gen(index);

0 commit comments

Comments
 (0)