2222//! are *mostly* used as a part of that interface, but these should
2323//! probably get a better home if someone can find one.
2424
25- use hir:: def;
2625use hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
2726use hir:: map as hir_map;
28- use hir:: map:: definitions:: { Definitions , DefKey , DefPathTable } ;
27+ use hir:: map:: definitions:: { DefKey , DefPathTable } ;
2928use hir:: svh:: Svh ;
3029use ty:: { self , TyCtxt } ;
3130use session:: { Session , CrateDisambiguator } ;
@@ -34,8 +33,6 @@ use session::search_paths::PathKind;
3433use std:: any:: Any ;
3534use std:: path:: { Path , PathBuf } ;
3635use syntax:: ast;
37- use syntax:: edition:: Edition ;
38- use syntax:: ext:: base:: SyntaxExtension ;
3936use syntax:: symbol:: Symbol ;
4037use syntax_pos:: Span ;
4138use rustc_target:: spec:: Target ;
@@ -140,11 +137,6 @@ pub struct ForeignModule {
140137 pub def_id : DefId ,
141138}
142139
143- pub enum LoadedMacro {
144- MacroDef ( ast:: Item ) ,
145- ProcMacro ( Lrc < SyntaxExtension > ) ,
146- }
147-
148140#[ derive( Copy , Clone , Debug ) ]
149141pub struct ExternCrate {
150142 pub src : ExternCrateSource ,
@@ -221,29 +213,18 @@ pub trait MetadataLoader {
221213pub trait CrateStore {
222214 fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Lrc < dyn Any > ;
223215
224- // access to the metadata loader
225- fn metadata_loader ( & self ) -> & dyn MetadataLoader ;
226-
227216 // resolve
228217 fn def_key ( & self , def : DefId ) -> DefKey ;
229218 fn def_path ( & self , def : DefId ) -> hir_map:: DefPath ;
230219 fn def_path_hash ( & self , def : DefId ) -> hir_map:: DefPathHash ;
231220 fn def_path_table ( & self , cnum : CrateNum ) -> Lrc < DefPathTable > ;
232221
233222 // "queries" used in resolve that aren't tracked for incremental compilation
234- fn visibility_untracked ( & self , def : DefId ) -> ty:: Visibility ;
235- fn export_macros_untracked ( & self , cnum : CrateNum ) ;
236- fn dep_kind_untracked ( & self , cnum : CrateNum ) -> DepKind ;
237223 fn crate_name_untracked ( & self , cnum : CrateNum ) -> Symbol ;
238224 fn crate_disambiguator_untracked ( & self , cnum : CrateNum ) -> CrateDisambiguator ;
239225 fn crate_hash_untracked ( & self , cnum : CrateNum ) -> Svh ;
240- fn crate_edition_untracked ( & self , cnum : CrateNum ) -> Edition ;
241- fn struct_field_names_untracked ( & self , def : DefId ) -> Vec < ast:: Name > ;
242- fn item_children_untracked ( & self , did : DefId , sess : & Session ) -> Vec < def:: Export > ;
243- fn load_macro_untracked ( & self , did : DefId , sess : & Session ) -> LoadedMacro ;
244226 fn extern_mod_stmt_cnum_untracked ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > ;
245227 fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics ;
246- fn associated_item_cloned_untracked ( & self , def : DefId ) -> ty:: AssociatedItem ;
247228 fn postorder_cnums_untracked ( & self ) -> Vec < CrateNum > ;
248229
249230 // This is basically a 1-based range of ints, which is a little
@@ -260,116 +241,6 @@ pub trait CrateStore {
260241
261242pub type CrateStoreDyn = dyn CrateStore + sync:: Sync ;
262243
263- // FIXME: find a better place for this?
264- pub fn validate_crate_name ( sess : Option < & Session > , s : & str , sp : Option < Span > ) {
265- let mut err_count = 0 ;
266- {
267- let mut say = |s : & str | {
268- match ( sp, sess) {
269- ( _, None ) => bug ! ( "{}" , s) ,
270- ( Some ( sp) , Some ( sess) ) => sess. span_err ( sp, s) ,
271- ( None , Some ( sess) ) => sess. err ( s) ,
272- }
273- err_count += 1 ;
274- } ;
275- if s. is_empty ( ) {
276- say ( "crate name must not be empty" ) ;
277- }
278- for c in s. chars ( ) {
279- if c. is_alphanumeric ( ) { continue }
280- if c == '_' { continue }
281- say ( & format ! ( "invalid character `{}` in crate name: `{}`" , c, s) ) ;
282- }
283- }
284-
285- if err_count > 0 {
286- sess. unwrap ( ) . abort_if_errors ( ) ;
287- }
288- }
289-
290- /// A dummy crate store that does not support any non-local crates,
291- /// for test purposes.
292- pub struct DummyCrateStore ;
293-
294- #[ allow( unused_variables) ]
295- impl CrateStore for DummyCrateStore {
296- fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Lrc < dyn Any >
297- { bug ! ( "crate_data_as_rc_any" ) }
298- // item info
299- fn visibility_untracked ( & self , def : DefId ) -> ty:: Visibility { bug ! ( "visibility" ) }
300- fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics
301- { bug ! ( "item_generics_cloned" ) }
302-
303- // trait/impl-item info
304- fn associated_item_cloned_untracked ( & self , def : DefId ) -> ty:: AssociatedItem
305- { bug ! ( "associated_item_cloned" ) }
306-
307- // crate metadata
308- fn dep_kind_untracked ( & self , cnum : CrateNum ) -> DepKind { bug ! ( "is_explicitly_linked" ) }
309- fn export_macros_untracked ( & self , cnum : CrateNum ) { bug ! ( "export_macros" ) }
310- fn crate_name_untracked ( & self , cnum : CrateNum ) -> Symbol { bug ! ( "crate_name" ) }
311- fn crate_disambiguator_untracked ( & self , cnum : CrateNum ) -> CrateDisambiguator {
312- bug ! ( "crate_disambiguator" )
313- }
314- fn crate_hash_untracked ( & self , cnum : CrateNum ) -> Svh { bug ! ( "crate_hash" ) }
315- fn crate_edition_untracked ( & self , cnum : CrateNum ) -> Edition { bug ! ( "crate_edition_untracked" ) }
316-
317- // resolve
318- fn def_key ( & self , def : DefId ) -> DefKey { bug ! ( "def_key" ) }
319- fn def_path ( & self , def : DefId ) -> hir_map:: DefPath {
320- bug ! ( "relative_def_path" )
321- }
322- fn def_path_hash ( & self , def : DefId ) -> hir_map:: DefPathHash {
323- bug ! ( "def_path_hash" )
324- }
325- fn def_path_table ( & self , cnum : CrateNum ) -> Lrc < DefPathTable > {
326- bug ! ( "def_path_table" )
327- }
328- fn struct_field_names_untracked ( & self , def : DefId ) -> Vec < ast:: Name > {
329- bug ! ( "struct_field_names" )
330- }
331- fn item_children_untracked ( & self , did : DefId , sess : & Session ) -> Vec < def:: Export > {
332- bug ! ( "item_children" )
333- }
334- fn load_macro_untracked ( & self , did : DefId , sess : & Session ) -> LoadedMacro { bug ! ( "load_macro" ) }
335-
336- fn crates_untracked ( & self ) -> Vec < CrateNum > { vec ! [ ] }
337-
338- // utility functions
339- fn extern_mod_stmt_cnum_untracked ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > { None }
340- fn encode_metadata < ' a , ' tcx > ( & self ,
341- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
342- link_meta : & LinkMeta )
343- -> EncodedMetadata {
344- bug ! ( "encode_metadata" )
345- }
346- fn metadata_encoding_version ( & self ) -> & [ u8 ] { bug ! ( "metadata_encoding_version" ) }
347- fn postorder_cnums_untracked ( & self ) -> Vec < CrateNum > { bug ! ( "postorder_cnums_untracked" ) }
348-
349- // access to the metadata loader
350- fn metadata_loader ( & self ) -> & dyn MetadataLoader { bug ! ( "metadata_loader" ) }
351- }
352-
353- pub trait CrateLoader {
354- fn process_extern_crate ( & mut self , item : & ast:: Item , defs : & Definitions ) -> CrateNum ;
355-
356- fn process_path_extern (
357- & mut self ,
358- name : Symbol ,
359- span : Span ,
360- ) -> CrateNum ;
361-
362- fn process_use_extern (
363- & mut self ,
364- name : Symbol ,
365- span : Span ,
366- id : ast:: NodeId ,
367- defs : & Definitions ,
368- ) -> CrateNum ;
369-
370- fn postprocess ( & mut self , krate : & ast:: Crate ) ;
371- }
372-
373244// This method is used when generating the command line to pass through to
374245// system linker. The linker expects undefined symbols on the left of the
375246// command line to be defined in libraries on the right, not the other way
0 commit comments