@@ -25,6 +25,7 @@ use rustc::hir::RangeEnd;
2525use rustc:: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
2626
2727use rustc:: mir:: Field ;
28+ use rustc:: mir:: interpret:: ConstValue ;
2829use rustc:: util:: common:: ErrorReported ;
2930
3031use syntax_pos:: { Span , DUMMY_SP } ;
@@ -932,16 +933,20 @@ fn slice_pat_covered_by_constructor<'tcx>(
932933 suffix : & [ Pattern < ' tcx > ]
933934) -> Result < bool , ErrorReported > {
934935 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
938943 . builtin_deref ( true )
939944 . and_then ( |t| t. ty . builtin_index ( ) )
940945 . map_or ( false , |t| t == tcx. types . u8 ) ;
941946 assert ! ( is_array_ptr) ;
942947 tcx. alloc_map . lock ( ) . unwrap_memory ( ptr. alloc_id ) . bytes . as_ref ( )
943948 } else {
944- bug ! ( )
949+ bug ! ( "unexpected non-ptr ConstantValue" )
945950 }
946951 }
947952 _ => bug ! ( )
0 commit comments