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.
34
45use crate :: MirPass ;
56use rustc_hir:: def_id:: DefId ;
@@ -10,15 +11,15 @@ use rustc_middle::mir::*;
1011use rustc_middle:: ty:: subst:: Subst ;
1112use rustc_middle:: ty:: TyCtxt ;
1213
13- struct ElaborateBoxDerefVistor < ' tcx , ' a > {
14+ struct ElaborateBoxDerefVisitor < ' tcx , ' a > {
1415 tcx : TyCtxt < ' tcx > ,
1516 unique_did : DefId ,
1617 nonnull_did : DefId ,
1718 local_decls : & ' a mut LocalDecls < ' tcx > ,
1819 patch : MirPatch < ' tcx > ,
1920}
2021
21- impl < ' tcx , ' a > MutVisitor < ' tcx > for ElaborateBoxDerefVistor < ' tcx , ' a > {
22+ impl < ' tcx , ' a > MutVisitor < ' tcx > for ElaborateBoxDerefVisitor < ' tcx , ' a > {
2223 fn tcx ( & self ) -> TyCtxt < ' tcx > {
2324 self . tcx
2425 }
@@ -90,7 +91,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
9091 let ( basic_blocks, local_decls) = body. basic_blocks_and_local_decls_mut ( ) ;
9192
9293 let mut visitor =
93- ElaborateBoxDerefVistor { tcx, unique_did, nonnull_did, local_decls, patch } ;
94+ ElaborateBoxDerefVisitor { tcx, unique_did, nonnull_did, local_decls, patch } ;
9495
9596 for ( block, BasicBlockData { statements, terminator, .. } ) in
9697 basic_blocks. iter_enumerated_mut ( )
@@ -111,7 +112,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateBoxDerefs {
111112
112113 let location = Location { block, statement_index : index } ;
113114 match terminator {
114- // yielding into a box is handed when lowering generators
115+ // yielding into a box is handled when lowering generators
115116 Some ( Terminator { kind : TerminatorKind :: Yield { value, .. } , .. } ) => {
116117 visitor. visit_operand ( value, location) ;
117118 }
0 commit comments