@@ -655,25 +655,6 @@ impl<'tcx> Constructor<'tcx> {
655
655
}
656
656
}
657
657
658
- fn display ( & self , tcx : TyCtxt < ' tcx > ) -> String {
659
- match self {
660
- Constructor :: ConstantValue ( val, _) => format ! ( "{}" , val) ,
661
- Constructor :: ConstantRange ( lo, hi, ty, range_end, _) => {
662
- // Get the right sign on the output:
663
- let ty = ty:: ParamEnv :: empty ( ) . and ( * ty) ;
664
- format ! (
665
- "{}{}{}" ,
666
- ty:: Const :: from_bits( tcx, * lo, ty) ,
667
- range_end,
668
- ty:: Const :: from_bits( tcx, * hi, ty) ,
669
- )
670
- }
671
- Constructor :: FixedLenSlice ( val) => format ! ( "[{}]" , val) ,
672
- Constructor :: VarLenSlice ( prefix, suffix) => format ! ( "[{}, .., {}]" , prefix, suffix) ,
673
- _ => bug ! ( "bad constructor being displayed: `{:?}" , self ) ,
674
- }
675
- }
676
-
677
658
// Returns the set of constructors covered by `self` but not by
678
659
// anything in `other_ctors`.
679
660
fn subtract_ctors (
@@ -1473,6 +1454,23 @@ impl<'tcx> IntRange<'tcx> {
1473
1454
let ( other_lo, other_hi) = ( * other. range . start ( ) , * other. range . end ( ) ) ;
1474
1455
( lo == other_hi || hi == other_lo)
1475
1456
}
1457
+
1458
+ fn display ( & self , tcx : TyCtxt < ' tcx > ) -> String {
1459
+ let ( lo, hi) = ( self . range . start ( ) , self . range . end ( ) ) ;
1460
+
1461
+ let bias = IntRange :: signed_bias ( tcx, self . ty ) ;
1462
+ let ( lo, hi) = ( lo ^ bias, hi ^ bias) ;
1463
+
1464
+ let ty = ty:: ParamEnv :: empty ( ) . and ( self . ty ) ;
1465
+ let lo_const = ty:: Const :: from_bits ( tcx, lo, ty) ;
1466
+ let hi_const = ty:: Const :: from_bits ( tcx, hi, ty) ;
1467
+
1468
+ if lo == hi {
1469
+ format ! ( "{}" , lo_const)
1470
+ } else {
1471
+ format ! ( "{}{}{}" , lo_const, RangeEnd :: Included , hi_const)
1472
+ }
1473
+ }
1476
1474
}
1477
1475
1478
1476
// Ignore spans when comparing, they don't carry semantic information as they are only for lints.
@@ -2118,9 +2116,7 @@ fn lint_overlapping_patterns(
2118
2116
int_range. span ,
2119
2117
& format ! (
2120
2118
"this range overlaps on `{}`" ,
2121
- IntRange { range: int_range. range, ty, span: DUMMY_SP }
2122
- . into_ctor( tcx)
2123
- . display( tcx) ,
2119
+ IntRange { range: int_range. range, ty, span: DUMMY_SP } . display( tcx) ,
2124
2120
) ,
2125
2121
) ;
2126
2122
}
0 commit comments