Skip to content

Commit ed0a798

Browse files
Drive-by get rid of a bunch of unnecessary :?
1 parent c00343a commit ed0a798

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

Diff for: compiler/rustc_mir_transform/src/validate.rs

+23-25
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'tcx> crate::MirPass<'tcx> for Validator {
5757
ty::Coroutine(..) => ExternAbi::Rust,
5858
// No need to do MIR validation on error bodies
5959
ty::Error(_) => return,
60-
_ => span_bug!(body.span, "unexpected body ty: {body_ty:?}"),
60+
_ => span_bug!(body.span, "unexpected body ty: {body_ty}"),
6161
};
6262

6363
ty::layout::fn_can_unwind(tcx, Some(def_id), body_abi)
@@ -662,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
662662
ProjectionElem::Index(index) => {
663663
let index_ty = self.body.local_decls[index].ty;
664664
if index_ty != self.tcx.types.usize {
665-
self.fail(location, format!("bad index ({index_ty:?} != usize)"))
665+
self.fail(location, format!("bad index ({index_ty} != usize)"))
666666
}
667667
}
668668
ProjectionElem::Deref
@@ -671,10 +671,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
671671
let base_ty = place_ref.ty(&self.body.local_decls, self.tcx).ty;
672672

673673
if base_ty.is_box() {
674-
self.fail(
675-
location,
676-
format!("{base_ty:?} dereferenced after ElaborateBoxDerefs"),
677-
)
674+
self.fail(location, format!("{base_ty} dereferenced after ElaborateBoxDerefs"))
678675
}
679676
}
680677
ProjectionElem::Field(f, ty) => {
@@ -687,7 +684,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
687684
this.fail(
688685
location,
689686
format!(
690-
"Field projection `{place_ref:?}.{f:?}` specified type `{ty:?}`, but actual type is `{f_ty:?}`"
687+
"Field projection `{place_ref:?}.{f:?}` specified type `{ty}`, but actual type is `{f_ty}`"
691688
)
692689
)
693690
}
@@ -813,7 +810,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
813810
self.fail(
814811
location,
815812
format!(
816-
"Failed subtyping {ty:#?} and {:#?}",
813+
"Failed subtyping {ty} and {}",
817814
place_ref.ty(&self.body.local_decls, self.tcx).ty
818815
),
819816
)
@@ -833,7 +830,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
833830
self.fail(
834831
location,
835832
format!(
836-
"Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty:?}"
833+
"Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty}"
837834
),
838835
);
839836
}
@@ -848,7 +845,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
848845
if ty.is_union() || ty.is_enum() {
849846
self.fail(
850847
START_BLOCK.start_location(),
851-
format!("invalid type {ty:?} in debuginfo for {:?}", debuginfo.name),
848+
format!("invalid type {ty} in debuginfo for {:?}", debuginfo.name),
852849
);
853850
}
854851
if projection.is_empty() {
@@ -1071,15 +1068,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10711068
if !self.mir_assign_valid_types(a, b) {
10721069
self.fail(
10731070
location,
1074-
format!("Cannot {op:?} compare incompatible types {a:?} and {b:?}"),
1071+
format!("Cannot {op:?} compare incompatible types {a} and {b}"),
10751072
);
10761073
}
10771074
} else if a != b {
10781075
self.fail(
10791076
location,
1080-
format!(
1081-
"Cannot perform binary op {op:?} on unequal types {a:?} and {b:?}"
1082-
),
1077+
format!("Cannot perform binary op {op:?} on unequal types {a} and {b}"),
10831078
);
10841079
}
10851080
}
@@ -1088,7 +1083,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
10881083
Offset => {
10891084
check_kinds!(a, "Cannot offset non-pointer type {:?}", ty::RawPtr(..));
10901085
if b != self.tcx.types.isize && b != self.tcx.types.usize {
1091-
self.fail(location, format!("Cannot offset by non-isize type {b:?}"));
1086+
self.fail(location, format!("Cannot offset by non-isize type {b}"));
10921087
}
10931088
}
10941089
Eq | Lt | Le | Ne | Ge | Gt => {
@@ -1320,7 +1315,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
13201315
{
13211316
self.fail(
13221317
location,
1323-
format!("Cannot transmute from non-`Sized` type {op_ty:?}"),
1318+
format!("Cannot transmute from non-`Sized` type {op_ty}"),
13241319
);
13251320
}
13261321
if !self
@@ -1347,7 +1342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
13471342
}
13481343
Rvalue::NullaryOp(NullOp::OffsetOf(indices), container) => {
13491344
let fail_out_of_bounds = |this: &mut Self, location, field, ty| {
1350-
this.fail(location, format!("Out of bounds field {field:?} for {ty:?}"));
1345+
this.fail(location, format!("Out of bounds field {field:?} for {ty}"));
13511346
};
13521347

13531348
let mut current_ty = *container;
@@ -1381,7 +1376,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
13811376
_ => {
13821377
self.fail(
13831378
location,
1384-
format!("Cannot get offset ({variant:?}, {field:?}) from type {current_ty:?}"),
1379+
format!("Cannot get offset ({variant:?}, {field:?}) from type {current_ty}"),
13851380
);
13861381
return;
13871382
}
@@ -1410,7 +1405,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
14101405
if !self.mir_assign_valid_types(unwrapped_ty, binder_inner_ty) {
14111406
self.fail(
14121407
location,
1413-
format!("Cannot wrap {unwrapped_ty:?} into unsafe binder {binder_ty:?}"),
1408+
format!("Cannot wrap {unwrapped_ty} into unsafe binder {binder_ty:?}"),
14141409
);
14151410
}
14161411
}
@@ -1496,24 +1491,27 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
14961491
// since CopyNonOverlapping is parametrized by 1 type,
14971492
// we only need to check that they are equal and not keep an extra parameter.
14981493
if !self.mir_assign_valid_types(op_src_ty, op_dst_ty) {
1499-
self.fail(location, format!("bad arg ({op_src_ty:?} != {op_dst_ty:?})"));
1494+
self.fail(location, format!("bad arg ({op_src_ty} != {op_dst_ty})"));
15001495
}
15011496

15021497
let op_cnt_ty = count.ty(&self.body.local_decls, self.tcx);
15031498
if op_cnt_ty != self.tcx.types.usize {
1504-
self.fail(location, format!("bad arg ({op_cnt_ty:?} != usize)"))
1499+
self.fail(location, format!("bad arg ({op_cnt_ty} != usize)"))
15051500
}
15061501
}
15071502
StatementKind::SetDiscriminant { place, .. } => {
15081503
if self.body.phase < MirPhase::Runtime(RuntimePhase::Initial) {
15091504
self.fail(location, "`SetDiscriminant`is not allowed until deaggregation");
15101505
}
1511-
let pty = place.ty(&self.body.local_decls, self.tcx).ty.kind();
1512-
if !matches!(pty, ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)) {
1506+
let pty = place.ty(&self.body.local_decls, self.tcx).ty;
1507+
if !matches!(
1508+
pty.kind(),
1509+
ty::Adt(..) | ty::Coroutine(..) | ty::Alias(ty::Opaque, ..)
1510+
) {
15131511
self.fail(
15141512
location,
15151513
format!(
1516-
"`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty:?}"
1514+
"`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty}"
15171515
),
15181516
);
15191517
}
@@ -1562,7 +1560,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
15621560
if ScalarInt::try_from_uint(value, size).is_none() {
15631561
self.fail(
15641562
location,
1565-
format!("the value {value:#x} is not a proper {switch_ty:?}"),
1563+
format!("the value {value:#x} is not a proper {switch_ty}"),
15661564
)
15671565
}
15681566
}

0 commit comments

Comments
 (0)