@@ -97,8 +97,7 @@ use std::cmp;
9797use std:: sync:: Arc ;
9898
9999use syntax:: symbol:: InternedString ;
100- use rustc:: dep_graph:: { WorkProductId , WorkProduct , DepNode , DepConstructor } ;
101- use rustc:: hir:: { CodegenFnAttrFlags , HirId } ;
100+ use rustc:: hir:: CodegenFnAttrFlags ;
102101use rustc:: hir:: def:: DefKind ;
103102use rustc:: hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE , CRATE_DEF_INDEX } ;
104103use rustc:: mir:: mono:: { Linkage , Visibility , CodegenUnitNameBuilder , CodegenUnit } ;
@@ -121,93 +120,6 @@ pub enum PartitioningStrategy {
121120 FixedUnitCount ( usize )
122121}
123122
124- pub trait CodegenUnitExt < ' tcx > {
125- fn as_codegen_unit ( & self ) -> & CodegenUnit < ' tcx > ;
126-
127- fn contains_item ( & self , item : & MonoItem < ' tcx > ) -> bool {
128- self . items ( ) . contains_key ( item)
129- }
130-
131- fn name < ' a > ( & ' a self ) -> & ' a InternedString
132- where ' tcx : ' a ,
133- {
134- & self . as_codegen_unit ( ) . name ( )
135- }
136-
137- fn items ( & self ) -> & FxHashMap < MonoItem < ' tcx > , ( Linkage , Visibility ) > {
138- & self . as_codegen_unit ( ) . items ( )
139- }
140-
141- fn work_product_id ( & self ) -> WorkProductId {
142- WorkProductId :: from_cgu_name ( & self . name ( ) . as_str ( ) )
143- }
144-
145- fn work_product ( & self , tcx : TyCtxt < ' _ , ' _ , ' _ > ) -> WorkProduct {
146- let work_product_id = self . work_product_id ( ) ;
147- tcx. dep_graph
148- . previous_work_product ( & work_product_id)
149- . unwrap_or_else ( || {
150- panic ! ( "Could not find work-product for CGU `{}`" , self . name( ) )
151- } )
152- }
153-
154- fn items_in_deterministic_order < ' a > ( & self ,
155- tcx : TyCtxt < ' a , ' tcx , ' tcx > )
156- -> Vec < ( MonoItem < ' tcx > ,
157- ( Linkage , Visibility ) ) > {
158- // The codegen tests rely on items being process in the same order as
159- // they appear in the file, so for local items, we sort by node_id first
160- #[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
161- pub struct ItemSortKey ( Option < HirId > , ty:: SymbolName ) ;
162-
163- fn item_sort_key < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
164- item : MonoItem < ' tcx > ) -> ItemSortKey {
165- ItemSortKey ( match item {
166- MonoItem :: Fn ( ref instance) => {
167- match instance. def {
168- // We only want to take HirIds of user-defined
169- // instances into account. The others don't matter for
170- // the codegen tests and can even make item order
171- // unstable.
172- InstanceDef :: Item ( def_id) => {
173- tcx. hir ( ) . as_local_hir_id ( def_id)
174- }
175- InstanceDef :: VtableShim ( ..) |
176- InstanceDef :: Intrinsic ( ..) |
177- InstanceDef :: FnPtrShim ( ..) |
178- InstanceDef :: Virtual ( ..) |
179- InstanceDef :: ClosureOnceShim { .. } |
180- InstanceDef :: DropGlue ( ..) |
181- InstanceDef :: CloneShim ( ..) => {
182- None
183- }
184- }
185- }
186- MonoItem :: Static ( def_id) => {
187- tcx. hir ( ) . as_local_hir_id ( def_id)
188- }
189- MonoItem :: GlobalAsm ( hir_id) => {
190- Some ( hir_id)
191- }
192- } , item. symbol_name ( tcx) )
193- }
194-
195- let mut items: Vec < _ > = self . items ( ) . iter ( ) . map ( |( & i, & l) | ( i, l) ) . collect ( ) ;
196- items. sort_by_cached_key ( |& ( i, _) | item_sort_key ( tcx, i) ) ;
197- items
198- }
199-
200- fn codegen_dep_node ( & self , tcx : TyCtxt < ' _ , ' tcx , ' tcx > ) -> DepNode {
201- DepNode :: new ( tcx, DepConstructor :: CompileCodegenUnit ( self . name ( ) . clone ( ) ) )
202- }
203- }
204-
205- impl < ' tcx > CodegenUnitExt < ' tcx > for CodegenUnit < ' tcx > {
206- fn as_codegen_unit ( & self ) -> & CodegenUnit < ' tcx > {
207- self
208- }
209- }
210-
211123// Anything we can't find a proper codegen unit for goes into this.
212124fn fallback_cgu_name ( name_builder : & mut CodegenUnitNameBuilder < ' _ , ' _ , ' _ > ) -> InternedString {
213125 name_builder. build_cgu_name ( LOCAL_CRATE , & [ "fallback" ] , Some ( "cgu" ) )
0 commit comments