@@ -57,7 +57,7 @@ impl<'tcx> crate::MirPass<'tcx> for Validator {
57
57
ty:: Coroutine ( ..) => ExternAbi :: Rust ,
58
58
// No need to do MIR validation on error bodies
59
59
ty:: Error ( _) => return ,
60
- _ => span_bug ! ( body. span, "unexpected body ty: {body_ty:? }" ) ,
60
+ _ => span_bug ! ( body. span, "unexpected body ty: {body_ty}" ) ,
61
61
} ;
62
62
63
63
ty:: layout:: fn_can_unwind ( tcx, Some ( def_id) , body_abi)
@@ -662,7 +662,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
662
662
ProjectionElem :: Index ( index) => {
663
663
let index_ty = self . body . local_decls [ index] . ty ;
664
664
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)" ) )
666
666
}
667
667
}
668
668
ProjectionElem :: Deref
@@ -671,10 +671,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
671
671
let base_ty = place_ref. ty ( & self . body . local_decls , self . tcx ) . ty ;
672
672
673
673
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" ) )
678
675
}
679
676
}
680
677
ProjectionElem :: Field ( f, ty) => {
@@ -687,7 +684,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
687
684
this. fail (
688
685
location,
689
686
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}`"
691
688
)
692
689
)
693
690
}
@@ -813,7 +810,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
813
810
self . fail (
814
811
location,
815
812
format ! (
816
- "Failed subtyping {ty:#? } and {:#? }" ,
813
+ "Failed subtyping {ty} and {}" ,
817
814
place_ref. ty( & self . body. local_decls, self . tcx) . ty
818
815
) ,
819
816
)
@@ -833,7 +830,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
833
830
self . fail (
834
831
location,
835
832
format ! (
836
- "Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty:? }"
833
+ "Cannot unwrap unsafe binder {binder_ty:?} into type {unwrapped_ty}"
837
834
) ,
838
835
) ;
839
836
}
@@ -848,7 +845,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
848
845
if ty. is_union ( ) || ty. is_enum ( ) {
849
846
self . fail (
850
847
START_BLOCK . start_location ( ) ,
851
- format ! ( "invalid type {ty:? } in debuginfo for {:?}" , debuginfo. name) ,
848
+ format ! ( "invalid type {ty} in debuginfo for {:?}" , debuginfo. name) ,
852
849
) ;
853
850
}
854
851
if projection. is_empty ( ) {
@@ -1071,15 +1068,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1071
1068
if !self . mir_assign_valid_types ( a, b) {
1072
1069
self . fail (
1073
1070
location,
1074
- format ! ( "Cannot {op:?} compare incompatible types {a:? } and {b:? }" ) ,
1071
+ format ! ( "Cannot {op:?} compare incompatible types {a} and {b}" ) ,
1075
1072
) ;
1076
1073
}
1077
1074
} else if a != b {
1078
1075
self . fail (
1079
1076
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}" ) ,
1083
1078
) ;
1084
1079
}
1085
1080
}
@@ -1088,7 +1083,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1088
1083
Offset => {
1089
1084
check_kinds ! ( a, "Cannot offset non-pointer type {:?}" , ty:: RawPtr ( ..) ) ;
1090
1085
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}" ) ) ;
1092
1087
}
1093
1088
}
1094
1089
Eq | Lt | Le | Ne | Ge | Gt => {
@@ -1320,7 +1315,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1320
1315
{
1321
1316
self . fail (
1322
1317
location,
1323
- format ! ( "Cannot transmute from non-`Sized` type {op_ty:? }" ) ,
1318
+ format ! ( "Cannot transmute from non-`Sized` type {op_ty}" ) ,
1324
1319
) ;
1325
1320
}
1326
1321
if !self
@@ -1347,7 +1342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1347
1342
}
1348
1343
Rvalue :: NullaryOp ( NullOp :: OffsetOf ( indices) , container) => {
1349
1344
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}" ) ) ;
1351
1346
} ;
1352
1347
1353
1348
let mut current_ty = * container;
@@ -1381,7 +1376,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1381
1376
_ => {
1382
1377
self . fail (
1383
1378
location,
1384
- format ! ( "Cannot get offset ({variant:?}, {field:?}) from type {current_ty:? }" ) ,
1379
+ format ! ( "Cannot get offset ({variant:?}, {field:?}) from type {current_ty}" ) ,
1385
1380
) ;
1386
1381
return ;
1387
1382
}
@@ -1410,7 +1405,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1410
1405
if !self . mir_assign_valid_types ( unwrapped_ty, binder_inner_ty) {
1411
1406
self . fail (
1412
1407
location,
1413
- format ! ( "Cannot wrap {unwrapped_ty:? } into unsafe binder {binder_ty:?}" ) ,
1408
+ format ! ( "Cannot wrap {unwrapped_ty} into unsafe binder {binder_ty:?}" ) ,
1414
1409
) ;
1415
1410
}
1416
1411
}
@@ -1496,24 +1491,27 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1496
1491
// since CopyNonOverlapping is parametrized by 1 type,
1497
1492
// we only need to check that they are equal and not keep an extra parameter.
1498
1493
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})" ) ) ;
1500
1495
}
1501
1496
1502
1497
let op_cnt_ty = count. ty ( & self . body . local_decls , self . tcx ) ;
1503
1498
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)" ) )
1505
1500
}
1506
1501
}
1507
1502
StatementKind :: SetDiscriminant { place, .. } => {
1508
1503
if self . body . phase < MirPhase :: Runtime ( RuntimePhase :: Initial ) {
1509
1504
self . fail ( location, "`SetDiscriminant`is not allowed until deaggregation" ) ;
1510
1505
}
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
+ ) {
1513
1511
self . fail (
1514
1512
location,
1515
1513
format ! (
1516
- "`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty:? }"
1514
+ "`SetDiscriminant` is only allowed on ADTs and coroutines, not {pty}"
1517
1515
) ,
1518
1516
) ;
1519
1517
}
@@ -1562,7 +1560,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
1562
1560
if ScalarInt :: try_from_uint ( value, size) . is_none ( ) {
1563
1561
self . fail (
1564
1562
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}" ) ,
1566
1564
)
1567
1565
}
1568
1566
}
0 commit comments