@@ -55,7 +55,7 @@ macro_rules! newtype_index {
5555pub struct Mir < ' tcx > {
5656 /// List of basic blocks. References to basic block use a newtyped index type `BasicBlock`
5757 /// that indexes into this vector.
58- pub basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
58+ basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
5959
6060 /// List of visibility (lexical) scopes; these are referenced by statements
6161 /// and used (eventually) for debuginfo. Indexed by a `VisibilityScope`.
@@ -94,18 +94,37 @@ pub struct Mir<'tcx> {
9494pub const START_BLOCK : BasicBlock = BasicBlock ( 0 ) ;
9595
9696impl < ' tcx > Mir < ' tcx > {
97- pub fn all_basic_blocks ( & self ) -> Vec < BasicBlock > {
98- ( 0 ..self . basic_blocks . len ( ) )
99- . map ( |i| BasicBlock :: new ( i) )
100- . collect ( )
97+ pub fn new ( basic_blocks : IndexVec < BasicBlock , BasicBlockData < ' tcx > > ,
98+ visibility_scopes : IndexVec < VisibilityScope , VisibilityScopeData > ,
99+ promoted : IndexVec < Promoted , Mir < ' tcx > > ,
100+ return_ty : FnOutput < ' tcx > ,
101+ var_decls : IndexVec < Var , VarDecl < ' tcx > > ,
102+ arg_decls : IndexVec < Arg , ArgDecl < ' tcx > > ,
103+ temp_decls : IndexVec < Temp , TempDecl < ' tcx > > ,
104+ upvar_decls : Vec < UpvarDecl > ,
105+ span : Span ) -> Self
106+ {
107+ Mir {
108+ basic_blocks : basic_blocks,
109+ visibility_scopes : visibility_scopes,
110+ promoted : promoted,
111+ return_ty : return_ty,
112+ var_decls : var_decls,
113+ arg_decls : arg_decls,
114+ temp_decls : temp_decls,
115+ upvar_decls : upvar_decls,
116+ span : span
117+ }
101118 }
102119
103- pub fn basic_block_data ( & self , bb : BasicBlock ) -> & BasicBlockData < ' tcx > {
104- & self . basic_blocks [ bb]
120+ #[ inline]
121+ pub fn basic_blocks ( & self ) -> & IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
122+ & self . basic_blocks
105123 }
106124
107- pub fn basic_block_data_mut ( & mut self , bb : BasicBlock ) -> & mut BasicBlockData < ' tcx > {
108- & mut self . basic_blocks [ bb]
125+ #[ inline]
126+ pub fn basic_blocks_mut ( & mut self ) -> & mut IndexVec < BasicBlock , BasicBlockData < ' tcx > > {
127+ & mut self . basic_blocks
109128 }
110129}
111130
@@ -114,14 +133,14 @@ impl<'tcx> Index<BasicBlock> for Mir<'tcx> {
114133
115134 #[ inline]
116135 fn index ( & self , index : BasicBlock ) -> & BasicBlockData < ' tcx > {
117- self . basic_block_data ( index )
136+ & self . basic_blocks ( ) [ index ]
118137 }
119138}
120139
121140impl < ' tcx > IndexMut < BasicBlock > for Mir < ' tcx > {
122141 #[ inline]
123142 fn index_mut ( & mut self , index : BasicBlock ) -> & mut BasicBlockData < ' tcx > {
124- self . basic_block_data_mut ( index )
143+ & mut self . basic_blocks_mut ( ) [ index ]
125144 }
126145}
127146
0 commit comments