1
- //! This pass transforms derefs of Box into a deref of the pointer inside Box
2
- //! Codegen does not allow box to be directly dereferenced
1
+ //! This pass transforms derefs of Box into a deref of the pointer inside Box.
2
+ //!
3
+ //! Box is not actually a pointer so it is incorrect to dereference it directly.
3
4
4
5
use crate :: MirPass ;
5
6
use rustc_hir:: def_id:: DefId ;
@@ -10,15 +11,15 @@ use rustc_middle::mir::*;
10
11
use rustc_middle:: ty:: subst:: Subst ;
11
12
use rustc_middle:: ty:: TyCtxt ;
12
13
13
- struct ElaborateBoxDerefVistor < ' tcx , ' a > {
14
+ struct ElaborateBoxDerefVisitor < ' tcx , ' a > {
14
15
tcx : TyCtxt < ' tcx > ,
15
16
unique_did : DefId ,
16
17
nonnull_did : DefId ,
17
18
local_decls : & ' a mut LocalDecls < ' tcx > ,
18
19
patch : MirPatch < ' tcx > ,
19
20
}
20
21
21
- impl < ' tcx , ' a > MutVisitor < ' tcx > for ElaborateBoxDerefVistor < ' tcx , ' a > {
22
+ impl < ' tcx , ' a > MutVisitor < ' tcx > for ElaborateBoxDerefVisitor < ' tcx , ' a > {
22
23
fn tcx ( & self ) -> TyCtxt < ' tcx > {
23
24
self . tcx
24
25
}
@@ -90,7 +91,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
90
91
let ( basic_blocks, local_decls) = body. basic_blocks_and_local_decls_mut ( ) ;
91
92
92
93
let mut visitor =
93
- ElaborateBoxDerefVistor { tcx, unique_did, nonnull_did, local_decls, patch } ;
94
+ ElaborateBoxDerefVisitor { tcx, unique_did, nonnull_did, local_decls, patch } ;
94
95
95
96
for ( block, BasicBlockData { statements, terminator, .. } ) in
96
97
basic_blocks. iter_enumerated_mut ( )
@@ -111,7 +112,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
111
112
112
113
let location = Location { block, statement_index : index } ;
113
114
match terminator {
114
- // yielding into a box is handed when lowering generators
115
+ // yielding into a box is handled when lowering generators
115
116
Some ( Terminator { kind : TerminatorKind :: Yield { value, .. } , .. } ) => {
116
117
visitor. visit_operand ( value, location) ;
117
118
}
0 commit comments