Skip to content

Commit 9c4c4a7

Browse files
committed
wip
1 parent b531630 commit 9c4c4a7

File tree

29 files changed

+74
-64
lines changed

29 files changed

+74
-64
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16071607
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
16081608
res, lifetime.ident, lifetime.ident.span
16091609
);
1610-
span_bug!(lifetime.ident.span, "{}", bug_msg);
1610+
span_bug!(lifetime.ident.span, "{bug_msg}");
16111611
}
16121612
};
16131613

compiler/rustc_ast_lowering/src/lifetime_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'ast> LifetimeCollectVisitor<'ast> {
3838
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
3939
res, lifetime.ident, lifetime.ident.span
4040
);
41-
span_bug!(lifetime.ident.span, "{}", bug_msg);
41+
span_bug!(lifetime.ident.span, "{bug_msg}");
4242
}
4343
}
4444
}

compiler/rustc_borrowck/src/constraint_generation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
7171
| TyContext::YieldTy(SourceInfo { span, .. })
7272
| TyContext::UserTy(span)
7373
| TyContext::LocalDecl { source_info: SourceInfo { span, .. }, .. } => {
74-
span_bug!(span, "should not be visiting outside of the CFG: {:?}", ty_context);
74+
span_bug!(span, "should not be visiting outside of the CFG: {ty_context:?}");
7575
}
7676
TyContext::Location(location) => {
7777
self.add_regular_live_constraint(ty, location);

compiler/rustc_builtin_macros/src/assert/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
159159
} else {
160160
format!(
161161
"Assertion failed: {escaped_expr_str}\nWith captures:\n{}",
162-
&self.fmt_string
162+
self.fmt_string
163163
)
164164
}),
165165
suffix: None,

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
480480
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
481481
self.0.sess.span_fatal(span, err.to_string())
482482
} else {
483-
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
483+
span_bug!(span, "failed to get layout for `{ty}`: {err}")
484484
}
485485
}
486486
}

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
107107
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
108108
}
109109
ErrorHandled::TooGeneric => {
110-
span_bug!(constant.span, "codegen encountered polymorphic constant: {:?}", err);
110+
span_bug!(constant.span, "codegen encountered polymorphic constant: {err:?}");
111111
}
112112
})
113113
.ok();

compiler/rustc_codegen_gcc/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
479479
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
480480
self.sess().emit_fatal(respan(span, err.into_diagnostic()))
481481
} else {
482-
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
482+
span_bug!(span, "failed to get layout for `{ty}`: {err}")
483483
}
484484
}
485485
}

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ fn link_natively<'a>(
971971
sess.emit_err(errors::UnableToExeLinker {
972972
linker_path,
973973
error: e,
974-
command_formatted: format!("{:?}", &cmd),
974+
command_formatted: format!("{cmd:?}"),
975975
});
976976
}
977977

@@ -1477,7 +1477,7 @@ fn print_native_static_libs(
14771477
sess.emit_note(errors::StaticLibraryNativeArtifacts);
14781478
// Prefix for greppability
14791479
// Note: This must not be translated as tools are allowed to depend on this exact string.
1480-
sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
1480+
sess.note_without_error(format!("native-static-libs: {}", lib_args.join(" ")));
14811481
}
14821482
}
14831483
}

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
313313
sym::link_section => {
314314
if let Some(val) = attr.value_str() {
315315
if val.as_str().bytes().any(|b| b == 0) {
316-
let msg = format!("illegal null byte in link_section value: `{}`", &val);
316+
let msg = format!("illegal null byte in link_section value: `{val}`");
317317
tcx.sess.span_err(attr.span, msg);
318318
} else {
319319
codegen_fn_attrs.link_section = Some(val);
@@ -648,7 +648,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
648648
if *ordinal <= u16::MAX as u128 {
649649
Some(*ordinal as u16)
650650
} else {
651-
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
651+
let msg = format!("ordinal value in `link_ordinal` is too large: `{ordinal}`");
652652
tcx.sess
653653
.struct_span_err(attr.span, msg)
654654
.note("the value may not exceed `u16::MAX`")

compiler/rustc_codegen_ssa/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn asm_const_to_str<'tcx>(
198198
ty_and_layout: TyAndLayout<'tcx>,
199199
) -> String {
200200
let ConstValue::Scalar(scalar) = const_value else {
201-
span_bug!(sp, "expected Scalar for promoted asm const, but got {:#?}", const_value)
201+
span_bug!(sp, "expected Scalar for promoted asm const, but got {const_value:#?}")
202202
};
203203
let value = scalar.assert_bits(ty_and_layout.size);
204204
match ty_and_layout.ty.kind() {

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
941941
}
942942
}
943943

944-
span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
944+
span_bug!(span, "receiver has no non-zero-sized fields {op:?}");
945945
}
946946

947947
// now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
@@ -983,13 +983,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
983983
}
984984
}
985985

986-
span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
986+
span_bug!(span, "receiver has no non-zero-sized fields {op:?}");
987987
}
988988

989989
// Make sure that we've actually unwrapped the rcvr down
990990
// to a pointer or ref to `dyn* Trait`.
991991
if !op.layout.ty.builtin_deref(true).unwrap().ty.is_dyn_star() {
992-
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
992+
span_bug!(span, "can't codegen a virtual call on {op:#?}");
993993
}
994994
let place = op.deref(bx.cx());
995995
let data_ptr = place.project_field(bx, 0);
@@ -1005,7 +1005,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10051005
continue;
10061006
}
10071007
_ => {
1008-
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
1008+
span_bug!(span, "can't codegen a virtual call on {op:#?}");
10091009
}
10101010
}
10111011
}

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
220220
// errored or at least linted
221221
ErrorHandled::Reported(_) => {}
222222
ErrorHandled::TooGeneric => {
223-
span_bug!(const_.span, "codegen encountered polymorphic constant: {:?}", err)
223+
span_bug!(const_.span, "codegen encountered polymorphic constant: {err:?}")
224224
}
225225
}
226226
}

compiler/rustc_const_eval/src/interpret/cast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9898
// No change to value
9999
self.write_immediate(*src, dest)?;
100100
}
101-
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {:?}", cast_ty),
101+
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {cast_ty:?}"),
102102
}
103103
}
104104

@@ -298,7 +298,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
298298
}
299299

300300
// Casts to bool are not permitted by rustc, no need to handle them here.
301-
_ => span_bug!(self.cur_span(), "invalid int to {:?} cast", cast_ty),
301+
_ => span_bug!(self.cur_span(), "invalid int to {cast_ty:?} cast"),
302302
})
303303
}
304304

@@ -331,7 +331,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
331331
// float -> f64
332332
Float(FloatTy::F64) => Scalar::from_f64(f.convert(&mut false).value),
333333
// That's it.
334-
_ => span_bug!(self.cur_span(), "invalid float to {:?} cast", dest_ty),
334+
_ => span_bug!(self.cur_span(), "invalid float to {dest_ty:?} cast"),
335335
}
336336
}
337337

compiler/rustc_const_eval/src/interpret/intern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ pub fn intern_const_alloc_recursive<
443443
} else if ecx.tcx.try_get_global_alloc(alloc_id).is_none() {
444444
// We have hit an `AllocId` that is neither in local or global memory and isn't
445445
// marked as dangling by local memory. That should be impossible.
446-
span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
446+
span_bug!(ecx.tcx.span, "encountered unknown alloc id {alloc_id:?}");
447447
}
448448
}
449449
Ok(())

compiler/rustc_const_eval/src/interpret/operator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
7676
Le => l <= r,
7777
Gt => l > r,
7878
Ge => l >= r,
79-
_ => span_bug!(self.cur_span(), "Invalid operation on char: {:?}", bin_op),
79+
_ => span_bug!(self.cur_span(), "Invalid operation on char: {bin_op:?}"),
8080
};
8181
(Scalar::from_bool(res), false, self.tcx.types.bool)
8282
}
@@ -99,7 +99,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
9999
BitAnd => l & r,
100100
BitOr => l | r,
101101
BitXor => l ^ r,
102-
_ => span_bug!(self.cur_span(), "Invalid operation on bool: {:?}", bin_op),
102+
_ => span_bug!(self.cur_span(), "Invalid operation on bool: {bin_op:?}"),
103103
};
104104
(Scalar::from_bool(res), false, self.tcx.types.bool)
105105
}
@@ -125,7 +125,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
125125
Mul => ((l * r).value.into(), ty),
126126
Div => ((l / r).value.into(), ty),
127127
Rem => ((l % r).value.into(), ty),
128-
_ => span_bug!(self.cur_span(), "invalid float op: `{:?}`", bin_op),
128+
_ => span_bug!(self.cur_span(), "invalid float op: `{bin_op:?}`"),
129129
};
130130
(val, false, ty)
131131
}
@@ -453,15 +453,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
453453
let val = val.to_bool()?;
454454
let res = match un_op {
455455
Not => !val,
456-
_ => span_bug!(self.cur_span(), "Invalid bool op {:?}", un_op),
456+
_ => span_bug!(self.cur_span(), "Invalid bool op {un_op:?}"),
457457
};
458458
Ok((Scalar::from_bool(res), false, self.tcx.types.bool))
459459
}
460460
ty::Float(fty) => {
461461
let res = match (un_op, fty) {
462462
(Neg, FloatTy::F32) => Scalar::from_f32(-val.to_f32()?),
463463
(Neg, FloatTy::F64) => Scalar::from_f64(-val.to_f64()?),
464-
_ => span_bug!(self.cur_span(), "Invalid float op {:?}", un_op),
464+
_ => span_bug!(self.cur_span(), "Invalid float op {un_op:?}"),
465465
};
466466
Ok((res, false, layout.ty))
467467
}

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
567567
} else if ty.is_floating_point() {
568568
self.check_op(ops::FloatingPointOp);
569569
} else {
570-
span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {:?}", ty);
570+
span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {ty:?}");
571571
}
572572
}
573573

@@ -715,7 +715,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
715715
return;
716716
}
717717
_ => {
718-
span_bug!(terminator.source_info.span, "invalid callee of type {:?}", fn_ty)
718+
span_bug!(terminator.source_info.span, "invalid callee of type {fn_ty:?}")
719719
}
720720
};
721721

compiler/rustc_const_eval/src/transform/promote_consts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl<'tcx> Validator<'_, 'tcx> {
249249
Q::in_any_value_of_ty(&self.ccx, return_ty)
250250
}
251251
kind => {
252-
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
252+
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
253253
}
254254
}
255255
}
@@ -290,7 +290,7 @@ impl<'tcx> Validator<'_, 'tcx> {
290290
}
291291
TerminatorKind::Yield { .. } => Err(Unpromotable),
292292
kind => {
293-
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
293+
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
294294
}
295295
}
296296
}
@@ -738,7 +738,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
738738
location
739739
}
740740
state => {
741-
span_bug!(self.promoted.span, "{:?} not promotable: {:?}", temp, state);
741+
span_bug!(self.promoted.span, "{temp:?} not promotable: {state:?}");
742742
}
743743
};
744744
if !self.keep_original {
@@ -759,7 +759,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
759759
let (mut rvalue, source_info) = {
760760
let statement = &mut self.source[loc.block].statements[loc.statement_index];
761761
let StatementKind::Assign(box (_, rhs)) = &mut statement.kind else {
762-
span_bug!(statement.source_info.span, "{:?} is not an assignment", statement);
762+
span_bug!(statement.source_info.span, "{statement:?} is not an assignment");
763763
};
764764

765765
(
@@ -787,7 +787,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
787787
let target = match &terminator.kind {
788788
TerminatorKind::Call { target: Some(target), .. } => *target,
789789
kind => {
790-
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
790+
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
791791
}
792792
};
793793
Terminator {
@@ -823,7 +823,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
823823
};
824824
}
825825
kind => {
826-
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
826+
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
827827
}
828828
};
829829
};

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,13 +1486,13 @@ impl HandlerInner {
14861486
self.failure(format!(
14871487
"For more information about an error, try \
14881488
`rustc --explain {}`.",
1489-
&error_codes[0]
1489+
error_codes[0]
14901490
));
14911491
} else {
14921492
self.failure(format!(
14931493
"For more information about this error, try \
14941494
`rustc --explain {}`.",
1495-
&error_codes[0]
1495+
error_codes[0]
14961496
));
14971497
}
14981498
}

compiler/rustc_expand/src/mbe/metavar_expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ fn parse_ident<'sess>(
134134
let token_str = pprust::token_to_string(token);
135135
let mut err = sess.span_diagnostic.struct_span_err(
136136
span,
137-
format!("expected identifier, found `{}`", &token_str)
137+
format!("expected identifier, found `{token_str}`")
138138
);
139139
err.span_suggestion(
140140
token.span,
141-
format!("try removing `{}`", &token_str),
141+
format!("try removing `{token_str}`"),
142142
"",
143143
Applicability::MaybeIncorrect,
144144
);

compiler/rustc_fluent_macro/src/fluent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
243243

244244
for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
245245
let snake_name = Ident::new(
246-
&format!("{}{}", &crate_prefix, &attr_name.replace('-', "_")),
246+
&format!("{}{}", crate_prefix, attr_name.replace('-', "_")),
247247
resource_str.span(),
248248
);
249249
if !previous_attrs.insert(snake_name.clone()) {

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,9 +1995,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19951995
// Missing try_into implementation for `{integer}` to `{float}`
19961996
err.multipart_suggestion_verbose(
19971997
format!(
1998-
"{}, producing the floating point representation of the integer, \
1999-
rounded if necessary",
2000-
&msg,
1998+
"{msg}, producing the floating point representation of the integer, \
1999+
rounded if necessary"
20012000
),
20022001
cast_suggestion,
20032002
Applicability::MaybeIncorrect, // lossy conversion

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,9 +873,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
873873
}
874874
(
875875
match parent_pred {
876-
None => format!("`{}`", &p),
876+
None => format!("`{p}`"),
877877
Some(parent_pred) => match format_pred(*parent_pred) {
878-
None => format!("`{}`", &p),
878+
None => format!("`{p}`"),
879879
Some((parent_p, _)) => {
880880
if !suggested
881881
&& !suggested_bounds.contains(pred)

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn report_unstable(
108108
) {
109109
let msg = match reason {
110110
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
111-
None => format!("use of unstable library feature '{}'", &feature),
111+
None => format!("use of unstable library feature '{feature}'"),
112112
};
113113

114114
if is_soft {

compiler/rustc_middle/src/mir/spanview.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ fn tooltip<'tcx>(
624624
) -> String {
625625
let source_map = tcx.sess.source_map();
626626
let mut text = Vec::new();
627-
text.push(format!("{}: {}:", spanview_id, &source_map.span_to_embeddable_string(span)));
627+
text.push(format!("{}: {}:", spanview_id, source_map.span_to_embeddable_string(span)));
628628
for statement in statements {
629629
let source_range = source_range_no_file(tcx, statement.source_info.span);
630630
text.push(format!(

0 commit comments

Comments
 (0)