@@ -152,7 +152,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
152152 * value, value. layout. size, value. layout. ty) ;
153153
154154 // Go over all the primitive types
155- match value. layout . ty . sty {
155+ let ty = value. layout . ty ;
156+ match ty. sty {
156157 ty:: Bool => {
157158 let value = value. to_scalar_or_undef ( ) ;
158159 try_validation ! ( value. to_bool( ) ,
@@ -175,7 +176,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
175176 // undef. We should fix that, but let's start low.
176177 }
177178 }
178- ty :: RawPtr ( .. ) | ty:: Ref ( .. ) => {
179+ _ if ty . is_box ( ) || ty. is_region_ptr ( ) || ty . is_unsafe_ptr ( ) => {
179180 // Handle fat pointers. We also check fat raw pointers,
180181 // their metadata must be valid!
181182 // This also checks that the ptr itself is initialized, which
@@ -184,7 +185,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
184185 "undefined data in pointer" , path) ;
185186 // Check metadata early, for better diagnostics
186187 if place. layout . is_unsized ( ) {
187- match self . tcx . struct_tail ( place. layout . ty ) . sty {
188+ let tail = self . tcx . struct_tail ( place. layout . ty ) ;
189+ match tail. sty {
188190 ty:: Dynamic ( ..) => {
189191 let vtable = try_validation ! ( place. extra. unwrap( ) . to_ptr( ) ,
190192 "non-pointer vtable in fat pointer" , path) ;
@@ -202,13 +204,11 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
202204 // Unsized, but not fat.
203205 }
204206 _ =>
205- bug ! ( "Unexpected unsized type tail: {:?}" ,
206- self . tcx. struct_tail( place. layout. ty)
207- ) ,
207+ bug ! ( "Unexpected unsized type tail: {:?}" , tail) ,
208208 }
209209 }
210210 // for safe ptrs, recursively check
211- if let ty :: Ref ( .. ) = value . layout . ty . sty {
211+ if !ty . is_unsafe_ptr ( ) {
212212 // Make sure this is non-NULL and aligned
213213 let ( size, align) = self . size_and_align_of ( place. extra , place. layout ) ?;
214214 match self . memory . check_align ( place. ptr , align) {
0 commit comments