@@ -25,6 +25,7 @@ use rustc::hir::RangeEnd;
25
25
use rustc:: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
26
26
27
27
use rustc:: mir:: Field ;
28
+ use rustc:: mir:: interpret:: ConstValue ;
28
29
use rustc:: util:: common:: ErrorReported ;
29
30
30
31
use syntax_pos:: { Span , DUMMY_SP } ;
@@ -932,16 +933,20 @@ fn slice_pat_covered_by_constructor<'tcx>(
932
933
suffix : & [ Pattern < ' tcx > ]
933
934
) -> Result < bool , ErrorReported > {
934
935
let data: & [ u8 ] = match * ctor {
935
- ConstantValue ( const_val @ & ty:: Const { val : ConstVal :: Value ( ..) , .. } ) => {
936
- if let Some ( ptr) = const_val. to_ptr ( ) {
937
- let is_array_ptr = const_val. ty
936
+ ConstantValue ( & ty:: Const { val : ConstVal :: Value ( const_val) , ty } ) => {
937
+ let val = match const_val {
938
+ ConstValue :: ByRef ( ..) => bug ! ( "unexpected ConstValue::ByRef" ) ,
939
+ ConstValue :: Scalar ( val) | ConstValue :: ScalarPair ( val, _) => val,
940
+ } ;
941
+ if let Ok ( ptr) = val. to_ptr ( ) {
942
+ let is_array_ptr = ty
938
943
. builtin_deref ( true )
939
944
. and_then ( |t| t. ty . builtin_index ( ) )
940
945
. map_or ( false , |t| t == tcx. types . u8 ) ;
941
946
assert ! ( is_array_ptr) ;
942
947
tcx. alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) . bytes . as_ref ( )
943
948
} else {
944
- bug ! ( )
949
+ bug ! ( "unexpected non-ptr ConstantValue" )
945
950
}
946
951
}
947
952
_ => bug ! ( )
0 commit comments