@@ -152,7 +152,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
152
152
* value, value. layout. size, value. layout. ty) ;
153
153
154
154
// Go over all the primitive types
155
- match value. layout . ty . sty {
155
+ let ty = value. layout . ty ;
156
+ match ty. sty {
156
157
ty:: Bool => {
157
158
let value = value. to_scalar_or_undef ( ) ;
158
159
try_validation ! ( value. to_bool( ) ,
@@ -175,7 +176,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
175
176
// undef. We should fix that, but let's start low.
176
177
}
177
178
}
178
- ty :: RawPtr ( .. ) | ty:: Ref ( .. ) => {
179
+ _ if ty . is_box ( ) || ty. is_region_ptr ( ) || ty . is_unsafe_ptr ( ) => {
179
180
// Handle fat pointers. We also check fat raw pointers,
180
181
// their metadata must be valid!
181
182
// 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>
184
185
"undefined data in pointer" , path) ;
185
186
// Check metadata early, for better diagnostics
186
187
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 {
188
190
ty:: Dynamic ( ..) => {
189
191
let vtable = try_validation ! ( place. extra. unwrap( ) . to_ptr( ) ,
190
192
"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>
202
204
// Unsized, but not fat.
203
205
}
204
206
_ =>
205
- bug ! ( "Unexpected unsized type tail: {:?}" ,
206
- self . tcx. struct_tail( place. layout. ty)
207
- ) ,
207
+ bug ! ( "Unexpected unsized type tail: {:?}" , tail) ,
208
208
}
209
209
}
210
210
// for safe ptrs, recursively check
211
- if let ty :: Ref ( .. ) = value . layout . ty . sty {
211
+ if !ty . is_unsafe_ptr ( ) {
212
212
// Make sure this is non-NULL and aligned
213
213
let ( size, align) = self . size_and_align_of ( place. extra , place. layout ) ?;
214
214
match self . memory . check_align ( place. ptr , align) {
0 commit comments