File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -201,8 +201,10 @@ fn is_cast_to_bigger_memory_layout<'tcx>(
201
201
202
202
// if the current expr looks like this `&mut expr[index]` then just looking
203
203
// at `expr[index]` won't give us the underlying allocation, so we just skip it
204
- // the same logic applies field access like `&mut expr.field`
205
- if let ExprKind :: Index ( ..) | ExprKind :: Field ( ..) = e_alloc. kind {
204
+ // the same logic applies field access `&mut expr.field` and reborrows `&mut *expr`.
205
+ if let ExprKind :: Index ( ..) | ExprKind :: Field ( ..) | ExprKind :: Unary ( UnOp :: Deref , ..) =
206
+ e_alloc. kind
207
+ {
206
208
return None ;
207
209
}
208
210
Original file line number Diff line number Diff line change @@ -261,6 +261,13 @@ unsafe fn bigger_layout() {
261
261
let ptr = r as * mut i32 as * mut Vec3 < i32 > ;
262
262
unsafe { * ptr = Vec3 ( 0 , 0 , 0 ) }
263
263
}
264
+
265
+ unsafe fn deref ( v : & mut Vec3 < i32 > ) {
266
+ let r = & mut v. 0 ;
267
+ let r = & mut * r;
268
+ let ptr = & mut * ( r as * mut i32 as * mut Vec3 < i32 > ) ;
269
+ unsafe { * ptr = Vec3 ( 0 , 0 , 0 ) }
270
+ }
264
271
}
265
272
266
273
const RAW_PTR : * mut u8 = 1 as * mut u8 ;
You can’t perform that action at this time.
0 commit comments