@@ -121,31 +121,34 @@ impl<'tcx> TypeFoldable<'tcx> for LvalueTy<'tcx> {
121121}
122122
123123impl < ' tcx > Lvalue < ' tcx > {
124- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> LvalueTy < ' tcx > {
124+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> LvalueTy < ' tcx >
125+ where D : HasLocalDecls < ' tcx >
126+ {
125127 match * self {
126128 Lvalue :: Local ( index) =>
127- LvalueTy :: Ty { ty : mir . local_decls [ index] . ty } ,
129+ LvalueTy :: Ty { ty : local_decls . local_decls ( ) [ index] . ty } ,
128130 Lvalue :: Static ( ref data) =>
129131 LvalueTy :: Ty { ty : data. ty } ,
130132 Lvalue :: Projection ( ref proj) =>
131- proj. base . ty ( mir , tcx) . projection_ty ( tcx, & proj. elem ) ,
133+ proj. base . ty ( local_decls , tcx) . projection_ty ( tcx, & proj. elem ) ,
132134 }
133135 }
134136}
135137
136138impl < ' tcx > Rvalue < ' tcx > {
137- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
139+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
140+ where D : HasLocalDecls < ' tcx >
138141 {
139142 match * self {
140- Rvalue :: Use ( ref operand) => operand. ty ( mir , tcx) ,
143+ Rvalue :: Use ( ref operand) => operand. ty ( local_decls , tcx) ,
141144 Rvalue :: Repeat ( ref operand, ref count) => {
142- let op_ty = operand. ty ( mir , tcx) ;
145+ let op_ty = operand. ty ( local_decls , tcx) ;
143146 let count = count. as_u64 ( tcx. sess . target . uint_type ) ;
144147 assert_eq ! ( count as usize as u64 , count) ;
145148 tcx. mk_array ( op_ty, count as usize )
146149 }
147150 Rvalue :: Ref ( reg, bk, ref lv) => {
148- let lv_ty = lv. ty ( mir , tcx) . to_ty ( tcx) ;
151+ let lv_ty = lv. ty ( local_decls , tcx) . to_ty ( tcx) ;
149152 tcx. mk_ref ( reg,
150153 ty:: TypeAndMut {
151154 ty : lv_ty,
@@ -156,22 +159,22 @@ impl<'tcx> Rvalue<'tcx> {
156159 Rvalue :: Len ( ..) => tcx. types . usize ,
157160 Rvalue :: Cast ( .., ty) => ty,
158161 Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
159- let lhs_ty = lhs. ty ( mir , tcx) ;
160- let rhs_ty = rhs. ty ( mir , tcx) ;
162+ let lhs_ty = lhs. ty ( local_decls , tcx) ;
163+ let rhs_ty = rhs. ty ( local_decls , tcx) ;
161164 op. ty ( tcx, lhs_ty, rhs_ty)
162165 }
163166 Rvalue :: CheckedBinaryOp ( op, ref lhs, ref rhs) => {
164- let lhs_ty = lhs. ty ( mir , tcx) ;
165- let rhs_ty = rhs. ty ( mir , tcx) ;
167+ let lhs_ty = lhs. ty ( local_decls , tcx) ;
168+ let rhs_ty = rhs. ty ( local_decls , tcx) ;
166169 let ty = op. ty ( tcx, lhs_ty, rhs_ty) ;
167170 tcx. intern_tup ( & [ ty, tcx. types . bool ] , false )
168171 }
169172 Rvalue :: UnaryOp ( UnOp :: Not , ref operand) |
170173 Rvalue :: UnaryOp ( UnOp :: Neg , ref operand) => {
171- operand. ty ( mir , tcx)
174+ operand. ty ( local_decls , tcx)
172175 }
173176 Rvalue :: Discriminant ( ref lval) => {
174- let ty = lval. ty ( mir , tcx) . to_ty ( tcx) ;
177+ let ty = lval. ty ( local_decls , tcx) . to_ty ( tcx) ;
175178 if let ty:: TyAdt ( adt_def, _) = ty. sty {
176179 adt_def. repr . discr_type ( ) . to_ty ( tcx)
177180 } else {
@@ -189,7 +192,7 @@ impl<'tcx> Rvalue<'tcx> {
189192 }
190193 AggregateKind :: Tuple => {
191194 tcx. mk_tup (
192- ops. iter ( ) . map ( |op| op. ty ( mir , tcx) ) ,
195+ ops. iter ( ) . map ( |op| op. ty ( local_decls , tcx) ) ,
193196 false
194197 )
195198 }
@@ -206,9 +209,11 @@ impl<'tcx> Rvalue<'tcx> {
206209}
207210
208211impl < ' tcx > Operand < ' tcx > {
209- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx > {
212+ pub fn ty < ' a , ' gcx , D > ( & self , local_decls : & D , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
213+ where D : HasLocalDecls < ' tcx >
214+ {
210215 match self {
211- & Operand :: Consume ( ref l) => l. ty ( mir , tcx) . to_ty ( tcx) ,
216+ & Operand :: Consume ( ref l) => l. ty ( local_decls , tcx) . to_ty ( tcx) ,
212217 & Operand :: Constant ( ref c) => c. ty ,
213218 }
214219 }
0 commit comments