@@ -29,13 +29,8 @@ fn build_ptr_tys<'tcx>(
29
29
pub ( super ) fn build_projection < ' tcx > (
30
30
unique_ty : Ty < ' tcx > ,
31
31
nonnull_ty : Ty < ' tcx > ,
32
- ptr_ty : Ty < ' tcx > ,
33
- ) -> [ PlaceElem < ' tcx > ; 3 ] {
34
- [
35
- PlaceElem :: Field ( FieldIdx :: ZERO , unique_ty) ,
36
- PlaceElem :: Field ( FieldIdx :: ZERO , nonnull_ty) ,
37
- PlaceElem :: Field ( FieldIdx :: ZERO , ptr_ty) ,
38
- ]
32
+ ) -> [ PlaceElem < ' tcx > ; 2 ] {
33
+ [ PlaceElem :: Field ( FieldIdx :: ZERO , unique_ty) , PlaceElem :: Field ( FieldIdx :: ZERO , nonnull_ty) ]
39
34
}
40
35
41
36
struct ElaborateBoxDerefVisitor < ' a , ' tcx > {
@@ -75,10 +70,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for ElaborateBoxDerefVisitor<'a, 'tcx> {
75
70
self . patch . add_assign (
76
71
location,
77
72
Place :: from ( ptr_local) ,
78
- Rvalue :: Use ( Operand :: Copy (
79
- Place :: from ( place. local )
80
- . project_deeper ( & build_projection ( unique_ty, nonnull_ty, ptr_ty) , tcx) ,
81
- ) ) ,
73
+ Rvalue :: Cast (
74
+ CastKind :: Transmute ,
75
+ Operand :: Copy (
76
+ Place :: from ( place. local )
77
+ . project_deeper ( & build_projection ( unique_ty, nonnull_ty) , tcx) ,
78
+ ) ,
79
+ ptr_ty,
80
+ ) ,
82
81
) ;
83
82
84
83
place. local = ptr_local;
@@ -133,8 +132,10 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
133
132
let ( unique_ty, nonnull_ty, ptr_ty) =
134
133
build_ptr_tys ( tcx, boxed_ty, unique_did, nonnull_did) ;
135
134
136
- new_projections
137
- . extend_from_slice ( & build_projection ( unique_ty, nonnull_ty, ptr_ty) ) ;
135
+ new_projections. extend_from_slice ( & build_projection ( unique_ty, nonnull_ty) ) ;
136
+ // While we can't project into `NonNull<_>` in a basic block
137
+ // due to MCP#807, this is debug info where it's fine.
138
+ new_projections. push ( PlaceElem :: Field ( FieldIdx :: ZERO , ptr_ty) ) ;
138
139
new_projections. push ( PlaceElem :: Deref ) ;
139
140
} else if let Some ( new_projections) = new_projections. as_mut ( ) {
140
141
// Keep building up our projections list once we've started it.
0 commit comments