Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
res, lifetime.ident, lifetime.ident.span
);
span_bug!(lifetime.ident.span, "{}", bug_msg);
span_bug!(lifetime.ident.span, "{bug_msg}");
}
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/lifetime_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'ast> LifetimeCollectVisitor<'ast> {
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
res, lifetime.ident, lifetime.ident.span
);
span_bug!(lifetime.ident.span, "{}", bug_msg);
span_bug!(lifetime.ident.span, "{bug_msg}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/constraint_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'cg, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'tcx> {
| TyContext::YieldTy(SourceInfo { span, .. })
| TyContext::UserTy(span)
| TyContext::LocalDecl { source_info: SourceInfo { span, .. }, .. } => {
span_bug!(span, "should not be visiting outside of the CFG: {:?}", ty_context);
span_bug!(span, "should not be visiting outside of the CFG: {ty_context:?}");
}
TyContext::Location(location) => {
self.add_regular_live_constraint(ty, location);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/assert/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
} else {
format!(
"Assertion failed: {escaped_expr_str}\nWith captures:\n{}",
&self.fmt_string
self.fmt_string
)
}),
suffix: None,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
self.0.sess.span_fatal(span, err.to_string())
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
span_bug!(span, "failed to get layout for `{ty}`: {err}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
}
ErrorHandled::TooGeneric => {
span_bug!(constant.span, "codegen encountered polymorphic constant: {:?}", err);
span_bug!(constant.span, "codegen encountered polymorphic constant: {err:?}");
}
})
.ok();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
self.sess().emit_fatal(respan(span, err.into_diagnostic()))
} else {
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
span_bug!(span, "failed to get layout for `{ty}`: {err}")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ fn link_natively<'a>(
sess.emit_err(errors::UnableToExeLinker {
linker_path,
error: e,
command_formatted: format!("{:?}", &cmd),
command_formatted: format!("{cmd:?}"),
});
}

Expand Down Expand Up @@ -1477,7 +1477,7 @@ fn print_native_static_libs(
sess.emit_note(errors::StaticLibraryNativeArtifacts);
// Prefix for greppability
// Note: This must not be translated as tools are allowed to depend on this exact string.
sess.note_without_error(format!("native-static-libs: {}", &lib_args.join(" ")));
sess.note_without_error(format!("native-static-libs: {}", lib_args.join(" ")));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
sym::link_section => {
if let Some(val) = attr.value_str() {
if val.as_str().bytes().any(|b| b == 0) {
let msg = format!("illegal null byte in link_section value: `{}`", &val);
let msg = format!("illegal null byte in link_section value: `{val}`");
tcx.sess.span_err(attr.span, msg);
} else {
codegen_fn_attrs.link_section = Some(val);
Expand Down Expand Up @@ -648,7 +648,7 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<u16> {
if *ordinal <= u16::MAX as u128 {
Some(*ordinal as u16)
} else {
let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
let msg = format!("ordinal value in `link_ordinal` is too large: `{ordinal}`");
tcx.sess
.struct_span_err(attr.span, msg)
.note("the value may not exceed `u16::MAX`")
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn asm_const_to_str<'tcx>(
ty_and_layout: TyAndLayout<'tcx>,
) -> String {
let ConstValue::Scalar(scalar) = const_value else {
span_bug!(sp, "expected Scalar for promoted asm const, but got {:#?}", const_value)
span_bug!(sp, "expected Scalar for promoted asm const, but got {const_value:#?}")
};
let value = scalar.assert_bits(ty_and_layout.size);
match ty_and_layout.ty.kind() {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
}

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

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

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

// Make sure that we've actually unwrapped the rcvr down
// to a pointer or ref to `dyn* Trait`.
if !op.layout.ty.builtin_deref(true).unwrap().ty.is_dyn_star() {
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
span_bug!(span, "can't codegen a virtual call on {op:#?}");
}
let place = op.deref(bx.cx());
let data_ptr = place.project_field(bx, 0);
Expand All @@ -1005,7 +1005,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
continue;
}
_ => {
span_bug!(span, "can't codegen a virtual call on {:#?}", op);
span_bug!(span, "can't codegen a virtual call on {op:#?}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// errored or at least linted
ErrorHandled::Reported(_) => {}
ErrorHandled::TooGeneric => {
span_bug!(const_.span, "codegen encountered polymorphic constant: {:?}", err)
span_bug!(const_.span, "codegen encountered polymorphic constant: {err:?}")
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_const_eval/src/interpret/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// No change to value
self.write_immediate(*src, dest)?;
}
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {:?}", cast_ty),
_ => span_bug!(self.cur_span(), "fn to unsafe fn cast on {cast_ty:?}"),
}
}

Expand Down Expand Up @@ -298,7 +298,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ pub fn intern_const_alloc_recursive<
} else if ecx.tcx.try_get_global_alloc(alloc_id).is_none() {
// We have hit an `AllocId` that is neither in local or global memory and isn't
// marked as dangling by local memory. That should be impossible.
span_bug!(ecx.tcx.span, "encountered unknown alloc id {:?}", alloc_id);
span_bug!(ecx.tcx.span, "encountered unknown alloc id {alloc_id:?}");
}
}
Ok(())
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_const_eval/src/interpret/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Le => l <= r,
Gt => l > r,
Ge => l >= r,
_ => span_bug!(self.cur_span(), "Invalid operation on char: {:?}", bin_op),
_ => span_bug!(self.cur_span(), "Invalid operation on char: {bin_op:?}"),
};
(Scalar::from_bool(res), false, self.tcx.types.bool)
}
Expand All @@ -99,7 +99,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
BitAnd => l & r,
BitOr => l | r,
BitXor => l ^ r,
_ => span_bug!(self.cur_span(), "Invalid operation on bool: {:?}", bin_op),
_ => span_bug!(self.cur_span(), "Invalid operation on bool: {bin_op:?}"),
};
(Scalar::from_bool(res), false, self.tcx.types.bool)
}
Expand All @@ -125,7 +125,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Mul => ((l * r).value.into(), ty),
Div => ((l / r).value.into(), ty),
Rem => ((l % r).value.into(), ty),
_ => span_bug!(self.cur_span(), "invalid float op: `{:?}`", bin_op),
_ => span_bug!(self.cur_span(), "invalid float op: `{bin_op:?}`"),
};
(val, false, ty)
}
Expand Down Expand Up @@ -453,15 +453,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let val = val.to_bool()?;
let res = match un_op {
Not => !val,
_ => span_bug!(self.cur_span(), "Invalid bool op {:?}", un_op),
_ => span_bug!(self.cur_span(), "Invalid bool op {un_op:?}"),
};
Ok((Scalar::from_bool(res), false, self.tcx.types.bool))
}
ty::Float(fty) => {
let res = match (un_op, fty) {
(Neg, FloatTy::F32) => Scalar::from_f32(-val.to_f32()?),
(Neg, FloatTy::F64) => Scalar::from_f64(-val.to_f64()?),
_ => span_bug!(self.cur_span(), "Invalid float op {:?}", un_op),
_ => span_bug!(self.cur_span(), "Invalid float op {un_op:?}"),
};
Ok((res, false, layout.ty))
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/transform/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
} else if ty.is_floating_point() {
self.check_op(ops::FloatingPointOp);
} else {
span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {:?}", ty);
span_bug!(self.span, "non-primitive type in `Rvalue::UnaryOp`: {ty:?}");
}
}

Expand Down Expand Up @@ -715,7 +715,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
return;
}
_ => {
span_bug!(terminator.source_info.span, "invalid callee of type {:?}", fn_ty)
span_bug!(terminator.source_info.span, "invalid callee of type {fn_ty:?}")
}
};

Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_const_eval/src/transform/promote_consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl<'tcx> Validator<'_, 'tcx> {
Q::in_any_value_of_ty(&self.ccx, return_ty)
}
kind => {
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
}
}
}
Expand Down Expand Up @@ -290,7 +290,7 @@ impl<'tcx> Validator<'_, 'tcx> {
}
TerminatorKind::Yield { .. } => Err(Unpromotable),
kind => {
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
}
}
}
Expand Down Expand Up @@ -738,7 +738,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
location
}
state => {
span_bug!(self.promoted.span, "{:?} not promotable: {:?}", temp, state);
span_bug!(self.promoted.span, "{temp:?} not promotable: {state:?}");
}
};
if !self.keep_original {
Expand All @@ -759,7 +759,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let (mut rvalue, source_info) = {
let statement = &mut self.source[loc.block].statements[loc.statement_index];
let StatementKind::Assign(box (_, rhs)) = &mut statement.kind else {
span_bug!(statement.source_info.span, "{:?} is not an assignment", statement);
span_bug!(statement.source_info.span, "{statement:?} is not an assignment");
};

(
Expand Down Expand Up @@ -787,7 +787,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
let target = match &terminator.kind {
TerminatorKind::Call { target: Some(target), .. } => *target,
kind => {
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
}
};
Terminator {
Expand Down Expand Up @@ -823,7 +823,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
};
}
kind => {
span_bug!(terminator.source_info.span, "{:?} not promotable", kind);
span_bug!(terminator.source_info.span, "{kind:?} not promotable");
}
};
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1486,13 +1486,13 @@ impl HandlerInner {
self.failure(format!(
"For more information about an error, try \
`rustc --explain {}`.",
&error_codes[0]
error_codes[0]
));
} else {
self.failure(format!(
"For more information about this error, try \
`rustc --explain {}`.",
&error_codes[0]
error_codes[0]
));
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/mbe/metavar_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ fn parse_ident<'sess>(
let token_str = pprust::token_to_string(token);
let mut err = sess.span_diagnostic.struct_span_err(
span,
format!("expected identifier, found `{}`", &token_str)
format!("expected identifier, found `{token_str}`")
);
err.span_suggestion(
token.span,
format!("try removing `{}`", &token_str),
format!("try removing `{token_str}`"),
"",
Applicability::MaybeIncorrect,
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok

for Attribute { id: Identifier { name: attr_name }, .. } in attributes {
let snake_name = Ident::new(
&format!("{}{}", &crate_prefix, &attr_name.replace('-', "_")),
&format!("{}{}", crate_prefix, attr_name.replace('-', "_")),
resource_str.span(),
);
if !previous_attrs.insert(snake_name.clone()) {
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1995,9 +1995,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Missing try_into implementation for `{integer}` to `{float}`
err.multipart_suggestion_verbose(
format!(
"{}, producing the floating point representation of the integer, \
rounded if necessary",
&msg,
"{msg}, producing the floating point representation of the integer, \
rounded if necessary"
),
cast_suggestion,
Applicability::MaybeIncorrect, // lossy conversion
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
(
match parent_pred {
None => format!("`{}`", &p),
None => format!("`{p}`"),
Some(parent_pred) => match format_pred(*parent_pred) {
None => format!("`{}`", &p),
None => format!("`{p}`"),
Some((parent_p, _)) => {
if !suggested
&& !suggested_bounds.contains(pred)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn report_unstable(
) {
let msg = match reason {
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
None => format!("use of unstable library feature '{}'", &feature),
None => format!("use of unstable library feature '{feature}'"),
};

if is_soft {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/spanview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ fn tooltip<'tcx>(
) -> String {
let source_map = tcx.sess.source_map();
let mut text = Vec::new();
text.push(format!("{}: {}:", spanview_id, &source_map.span_to_embeddable_string(span)));
text.push(format!("{}: {}:", spanview_id, source_map.span_to_embeddable_string(span)));
for statement in statements {
let source_range = source_range_no_file(tcx, statement.source_info.span);
text.push(format!(
Expand Down
Loading