@@ -13,12 +13,12 @@ use crate::hair::constant::*;
13
13
use rustc:: lint;
14
14
use rustc:: mir:: { Field , BorrowKind , Mutability } ;
15
15
use rustc:: mir:: { UserTypeProjection } ;
16
- use rustc:: mir:: interpret:: { GlobalId , ConstValue , sign_extend , AllocId , Pointer } ;
16
+ use rustc:: mir:: interpret:: { GlobalId , ConstValue , get_slice_bytes , sign_extend } ;
17
17
use rustc:: traits:: { ObligationCause , PredicateObligation } ;
18
18
use rustc:: ty:: { self , Region , TyCtxt , AdtDef , Ty , UserType , DefIdTree } ;
19
19
use rustc:: ty:: { CanonicalUserType , CanonicalUserTypeAnnotation , CanonicalUserTypeAnnotations } ;
20
20
use rustc:: ty:: subst:: { SubstsRef , GenericArg } ;
21
- use rustc:: ty:: layout:: { VariantIdx , Size } ;
21
+ use rustc:: ty:: layout:: VariantIdx ;
22
22
use rustc:: hir:: { self , RangeEnd } ;
23
23
use rustc:: hir:: def:: { CtorOf , Res , DefKind , CtorKind } ;
24
24
use rustc:: hir:: pat_util:: EnumerateAndAdjustIterator ;
@@ -1526,27 +1526,10 @@ pub fn compare_const_vals<'tcx>(
1526
1526
1527
1527
if let ty:: Str = ty. kind {
1528
1528
match ( a. val , b. val ) {
1529
- (
1530
- ConstValue :: Slice { data : alloc_a, start : offset_a, end : end_a } ,
1531
- ConstValue :: Slice { data : alloc_b, start : offset_b, end : end_b } ,
1532
- ) => {
1533
- let len_a = end_a - offset_a;
1534
- let len_b = end_b - offset_b;
1535
- let a = alloc_a. get_bytes (
1536
- & tcx,
1537
- // invent a pointer, only the offset is relevant anyway
1538
- Pointer :: new ( AllocId ( 0 ) , Size :: from_bytes ( offset_a as u64 ) ) ,
1539
- Size :: from_bytes ( len_a as u64 ) ,
1540
- ) ;
1541
- let b = alloc_b. get_bytes (
1542
- & tcx,
1543
- // invent a pointer, only the offset is relevant anyway
1544
- Pointer :: new ( AllocId ( 0 ) , Size :: from_bytes ( offset_b as u64 ) ) ,
1545
- Size :: from_bytes ( len_b as u64 ) ,
1546
- ) ;
1547
- if let ( Ok ( a) , Ok ( b) ) = ( a, b) {
1548
- return from_bool ( a == b) ;
1549
- }
1529
+ ( ConstValue :: Slice { .. } , ConstValue :: Slice { .. } ) => {
1530
+ let a_bytes = get_slice_bytes ( & tcx, a. val ) ;
1531
+ let b_bytes = get_slice_bytes ( & tcx, b. val ) ;
1532
+ return from_bool ( a_bytes == b_bytes) ;
1550
1533
}
1551
1534
_ => ( ) ,
1552
1535
}
0 commit comments