@@ -13,12 +13,12 @@ use crate::hair::constant::*;
1313use rustc:: lint;
1414use rustc:: mir:: { Field , BorrowKind , Mutability } ;
1515use 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 } ;
1717use rustc:: traits:: { ObligationCause , PredicateObligation } ;
1818use rustc:: ty:: { self , Region , TyCtxt , AdtDef , Ty , UserType , DefIdTree } ;
1919use rustc:: ty:: { CanonicalUserType , CanonicalUserTypeAnnotation , CanonicalUserTypeAnnotations } ;
2020use rustc:: ty:: subst:: { SubstsRef , GenericArg } ;
21- use rustc:: ty:: layout:: { VariantIdx , Size } ;
21+ use rustc:: ty:: layout:: VariantIdx ;
2222use rustc:: hir:: { self , RangeEnd } ;
2323use rustc:: hir:: def:: { CtorOf , Res , DefKind , CtorKind } ;
2424use rustc:: hir:: pat_util:: EnumerateAndAdjustIterator ;
@@ -1526,27 +1526,10 @@ pub fn compare_const_vals<'tcx>(
15261526
15271527 if let ty:: Str = ty. kind {
15281528 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) ;
15501533 }
15511534 _ => ( ) ,
15521535 }
0 commit comments