@@ -39,7 +39,7 @@ use rustc::middle::weak_lang_items;
3939use rustc:: mir:: mono:: { Linkage , Visibility , Stats , CodegenUnitNameBuilder } ;
4040use rustc:: middle:: cstore:: { EncodedMetadata } ;
4141use rustc:: ty:: { self , Ty , TyCtxt } ;
42- use rustc:: ty:: layout:: { self , Align , TyLayout , LayoutOf } ;
42+ use rustc:: ty:: layout:: { self , Align , TyLayout , LayoutOf , HasTyCtxt } ;
4343use rustc:: ty:: query:: Providers ;
4444use rustc:: middle:: cstore:: { self , LinkagePreference } ;
4545use rustc:: middle:: exported_symbols;
@@ -56,7 +56,6 @@ use callee;
5656use rustc_mir:: monomorphize:: collector:: { self , MonoItemCollectionMode } ;
5757use rustc_mir:: monomorphize:: item:: DefPathBasedNames ;
5858use common:: { self , IntPredicate , RealPredicate , TypeKind } ;
59- use consts;
6059use context:: CodegenCx ;
6160use debuginfo;
6261use declare;
@@ -188,16 +187,16 @@ pub fn compare_simd_types<'a, 'll:'a, 'tcx:'ll, Builder : BuilderMethods<'a, 'll
188187/// The `old_info` argument is a bit funny. It is intended for use
189188/// in an upcast, where the new vtable for an object will be derived
190189/// from the old one.
191- pub fn unsized_info (
192- cx : & CodegenCx < ' ll , ' tcx , & ' ll Value > ,
190+ pub fn unsized_info < ' a , ' ll : ' a , ' tcx : ' ll , Cx : ' a + CodegenMethods < ' ll , ' tcx > > (
191+ cx : & ' a Cx ,
193192 source : Ty < ' tcx > ,
194193 target : Ty < ' tcx > ,
195- old_info : Option < & ' ll Value > ,
196- ) -> & ' ll Value {
197- let ( source, target) = cx. tcx . struct_lockstep_tails ( source, target) ;
194+ old_info : Option < Cx :: Value > ,
195+ ) -> Cx :: Value where & ' a Cx : LayoutOf < Ty = Ty < ' tcx > , TyLayout = TyLayout < ' tcx > > + HasTyCtxt < ' tcx > {
196+ let ( source, target) = cx. tcx ( ) . struct_lockstep_tails ( source, target) ;
198197 match ( & source. sty , & target. sty ) {
199198 ( & ty:: Array ( _, len) , & ty:: Slice ( _) ) => {
200- cx. const_usize ( len. unwrap_usize ( cx. tcx ) )
199+ cx. const_usize ( len. unwrap_usize ( * cx. tcx ( ) ) )
201200 }
202201 ( & ty:: Dynamic ( ..) , & ty:: Dynamic ( ..) ) => {
203202 // For now, upcasts are limited to changes in marker
@@ -206,10 +205,10 @@ pub fn unsized_info(
206205 old_info. expect ( "unsized_info: missing old info for trait upcast" )
207206 }
208207 ( _, & ty:: Dynamic ( ref data, ..) ) => {
209- let vtable_ptr = cx. layout_of ( cx. tcx . mk_mut_ptr ( target) )
208+ let vtable_ptr = cx. layout_of ( cx. tcx ( ) . mk_mut_ptr ( target) )
210209 . field ( cx, abi:: FAT_PTR_EXTRA ) ;
211- consts :: ptrcast ( meth:: get_vtable ( cx, source, data. principal ( ) ) ,
212- vtable_ptr . llvm_type ( cx ) )
210+ cx . static_ptrcast ( meth:: get_vtable ( cx, source, data. principal ( ) ) ,
211+ cx . backend_type ( vtable_ptr ) )
213212 }
214213 _ => bug ! ( "unsized_info: invalid unsizing {:?} -> {:?}" ,
215214 source,
0 commit comments