mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Drive-by get rid of a bunch of unnecessary :?
This commit is contained in:
@@ -57,7 +57,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
ty::Coroutine(..) => ExternAbi::Rust,
|
||||
// No need to do MIR validation on error bodies
|
||||
ty::Error(_) => return,
|
||||
_ => span_bug!(body.span, "unexpected body ty: {body_ty:?}"),
|
||||
_ => span_bug!(body.span, "unexpected body ty: {body_ty}"),
|
||||
};
|
||||
|
||||
ty::layout::fn_can_unwind(tcx, Some(def_id), body_abi)
|
||||
@@ -662,7 +662,7 @@ fn visit_projection_elem(
|
||||
ProjectionElem::Index(index) => {
|
||||
let index_ty = self.body.local_decls[index].ty;
|
||||
if index_ty != self.tcx.types.usize {
|
||||
self.fail(location, format!("bad index ({index_ty:?} != usize)"))
|
||||
self.fail(location, format!("bad index ({index_ty} != usize)"))
|
||||
}
|
||||
}
|
||||
ProjectionElem::Deref
|
||||
@@ -671,10 +671,7 @@ fn visit_projection_elem(
|
||||
let base_ty = place_ref.ty(&self.body.local_decls, self.tcx).ty;
|
||||
|
||||
if base_ty.is_box() {
|
||||
self.fail(
|
||||
location,
|
||||
format!("{base_ty:?} dereferenced after ElaborateBoxDerefs"),
|
||||
)
|
||||
self.fail(location, format!("{base_ty} dereferenced after ElaborateBoxDerefs"))
|
||||
}
|
||||
}
|
||||
ProjectionElem::Field(f, ty) => {
|
||||
@@ -687,7 +684,7 @@ fn visit_projection_elem(
|
||||
this.fail(
|
||||
location,
|
||||
format!(
|
||||
"Field projection `{place_ref:?}.{f:?}` specified type `{ty:?}`, but actual type is `{f_ty:?}`"
|
||||
"Field projection `{place_ref:?}.{f:?}` specified type `{ty}`, but actual type is `{f_ty}`"
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -813,7 +810,7 @@ fn visit_projection_elem(
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
"Failed subtyping {ty:#?} and {:#?}",
|
||||
"Failed subtyping {ty} and {}",
|
||||
place_ref.ty(&self.body.local_decls, self.tcx).ty
|
||||
),
|
||||
)
|
||||
@@ -833,7 +830,7 @@ fn visit_projection_elem(
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
"Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty:?}"
|
||||
"Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty}"
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -848,7 +845,7 @@ fn visit_var_debug_info(&mut self, debuginfo: &VarDebugInfo<'tcx>) {
|
||||
if ty.is_union() || ty.is_enum() {
|
||||
self.fail(
|
||||
START_BLOCK.start_location(),
|
||||
format!("invalid type {ty:?} in debuginfo for {:?}", debuginfo.name),
|
||||
format!("invalid type {ty} in debuginfo for {:?}", debuginfo.name),
|
||||
);
|
||||
}
|
||||
if projection.is_empty() {
|
||||
@@ -1071,15 +1068,13 @@ macro_rules! check_kinds {
|
||||
if !self.mir_assign_valid_types(a, b) {
|
||||
self.fail(
|
||||
location,
|
||||
format!("Cannot {op:?} compare incompatible types {a:?} and {b:?}"),
|
||||
format!("Cannot {op:?} compare incompatible types {a} and {b}"),
|
||||
);
|
||||
}
|
||||
} else if a != b {
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
"Cannot perform binary op {op:?} on unequal types {a:?} and {b:?}"
|
||||
),
|
||||
format!("Cannot perform binary op {op:?} on unequal types {a} and {b}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1088,7 +1083,7 @@ macro_rules! check_kinds {
|
||||
Offset => {
|
||||
check_kinds!(a, "Cannot offset non-pointer type {:?}", ty::RawPtr(..));
|
||||
if b != self.tcx.types.isize && b != self.tcx.types.usize {
|
||||
self.fail(location, format!("Cannot offset by non-isize type {b:?}"));
|
||||
self.fail(location, format!("Cannot offset by non-isize type {b}"));
|
||||
}
|
||||
}
|
||||
Eq | Lt | Le | Ne | Ge | Gt => {
|
||||
@@ -1320,7 +1315,7 @@ macro_rules! check_kinds {
|
||||
{
|
||||
self.fail(
|
||||
location,
|
||||
format!("Cannot transmute from non-`Sized` type {op_ty:?}"),
|
||||
format!("Cannot transmute from non-`Sized` type {op_ty}"),
|
||||
);
|
||||
}
|
||||
if !self
|
||||
@@ -1347,7 +1342,7 @@ macro_rules! check_kinds {
|
||||
}
|
||||
Rvalue::NullaryOp(NullOp::OffsetOf(indices), container) => {
|
||||
let fail_out_of_bounds = |this: &mut Self, location, field, ty| {
|
||||
this.fail(location, format!("Out of bounds field {field:?} for {ty:?}"));
|
||||
this.fail(location, format!("Out of bounds field {field:?} for {ty}"));
|
||||
};
|
||||
|
||||
let mut current_ty = *container;
|
||||
@@ -1381,7 +1376,7 @@ macro_rules! check_kinds {
|
||||
_ => {
|
||||
self.fail(
|
||||
location,
|
||||
format!("Cannot get offset ({variant:?}, {field:?}) from type {current_ty:?}"),
|
||||
format!("Cannot get offset ({variant:?}, {field:?}) from type {current_ty}"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -1410,7 +1405,7 @@ macro_rules! check_kinds {
|
||||
if !self.mir_assign_valid_types(unwrapped_ty, binder_inner_ty) {
|
||||
self.fail(
|
||||
location,
|
||||
format!("Cannot wrap {unwrapped_ty:?} into unsafe binder {binder_ty:?}"),
|
||||
format!("Cannot wrap {unwrapped_ty} into unsafe binder {binder_ty:?}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1496,24 +1491,27 @@ fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
||||
// since CopyNonOverlapping is parametrized by 1 type,
|
||||
// we only need to check that they are equal and not keep an extra parameter.
|
||||
if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) {
|
||||
self.fail(location, format!("bad arg ({op_src_ty:?} != {op_dst_ty:?})"));
|
||||
self.fail(location, format!("bad arg ({op_src_ty} != {op_dst_ty})"));
|
||||
}
|
||||
|
||||
let op_cnt_ty = count.ty(&self.body.local_decls, self.tcx);
|
||||
if op_cnt_ty != self.tcx.types.usize {
|
||||
self.fail(location, format!("bad arg ({op_cnt_ty:?} != usize)"))
|
||||
self.fail(location, format!("bad arg ({op_cnt_ty} != usize)"))
|
||||
}
|
||||
}
|
||||
StatementKind::SetDiscriminant { place, .. } => {
|
||||
if self.body.phase < MirPhase::Runtime(RuntimePhase::Initial) {
|
||||
self.fail(location, "`SetDiscriminant`is not allowed until deaggregation");
|
||||
}
|
||||
let pty = place.ty(&self.body.local_decls, self.tcx).ty.kind();
|
||||
if !matches!(pty, ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)) {
|
||||
let pty = place.ty(&self.body.local_decls, self.tcx).ty;
|
||||
if !matches!(
|
||||
pty.kind(),
|
||||
ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)
|
||||
) {
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
"`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty:?}"
|
||||
"`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty}"
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1562,7 +1560,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
if ScalarInt::try_from_uint(value, size).is_none() {
|
||||
self.fail(
|
||||
location,
|
||||
format!("the value {value:#x} is not a proper {switch_ty:?}"),
|
||||
format!("the value {value:#x} is not a proper {switch_ty}"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user