@@ -22,8 +22,10 @@ use rustc_middle::bug;
2222use rustc_middle:: ty:: data_structures:: IndexSet ;
2323use rustc_middle:: ty:: { TyCtxt , TyCtxtFeed } ;
2424use rustc_proc_macro:: bridge:: client:: ProcMacro ;
25+ use rustc_session:: Session ;
2526use rustc_session:: config:: {
26- CrateType , ExtendedTargetModifierInfo , ExternLocation , OptionsTargetModifiers , TargetModifier ,
27+ CrateType , ExtendedTargetModifierInfo , ExternLocation , Externs , OptionsTargetModifiers ,
28+ TargetModifier ,
2729} ;
2830use rustc_session:: cstore:: { CrateDepKind , CrateSource , ExternCrate , ExternCrateSource } ;
2931use rustc_session:: lint:: { self , BuiltinLintDiag } ;
@@ -480,7 +482,7 @@ impl CStore {
480482
481483 fn existing_match (
482484 & self ,
483- tcx : TyCtxt < ' _ > ,
485+ externs : & Externs ,
484486 name : Symbol ,
485487 hash : Option < Svh > ,
486488 kind : PathKind ,
@@ -510,7 +512,7 @@ impl CStore {
510512 // `source` stores paths which are normalized which may be different
511513 // from the strings on the command line.
512514 let source = self . get_crate_data ( cnum) . cdata . source ( ) ;
513- if let Some ( entry) = tcx . sess . opts . externs . get ( name. as_str ( ) ) {
515+ if let Some ( entry) = externs. get ( name. as_str ( ) ) {
514516 // Only use `--extern crate_name=path` here, not `--extern crate_name`.
515517 if let Some ( mut files) = entry. files ( ) {
516518 if files. any ( |l| {
@@ -561,9 +563,9 @@ impl CStore {
561563 /// Sometimes the directly dependent crate is not specified by `--extern`, in this case,
562564 /// `private-dep` is none during loading. This is equivalent to the scenario where the
563565 /// command parameter is set to `public-dependency`
564- fn is_private_dep < ' tcx > (
566+ fn is_private_dep (
565567 & self ,
566- tcx : TyCtxt < ' tcx > ,
568+ externs : & Externs ,
567569 name : Symbol ,
568570 private_dep : Option < bool > ,
569571 origin : CrateOrigin < ' _ > ,
@@ -572,7 +574,7 @@ impl CStore {
572574 return true ;
573575 }
574576
575- let extern_private = tcx . sess . opts . externs . get ( name. as_str ( ) ) . map ( |e| e. is_private_dep ) ;
577+ let extern_private = externs. get ( name. as_str ( ) ) . map ( |e| e. is_private_dep ) ;
576578 match ( extern_private, private_dep) {
577579 // Explicit non-private via `--extern`, explicit non-private from metadata, or
578580 // unspecified with default to public.
@@ -598,7 +600,7 @@ impl CStore {
598600 let Library { source, metadata } = lib;
599601 let crate_root = metadata. get_root ( ) ;
600602 let host_hash = host_lib. as_ref ( ) . map ( |lib| lib. metadata . get_root ( ) . hash ( ) ) ;
601- let private_dep = self . is_private_dep ( tcx, name, private_dep, origin) ;
603+ let private_dep = self . is_private_dep ( & tcx. sess . opts . externs , name, private_dep, origin) ;
602604
603605 // Claim this crate number and cache it
604606 let feed = self . intern_stable_crate_id ( tcx, & crate_root) ?;
@@ -641,7 +643,7 @@ impl CStore {
641643 None => ( & source, & crate_root) ,
642644 } ;
643645 let dlsym_dylib = dlsym_source. dylib . as_ref ( ) . expect ( "no dylib for a proc-macro crate" ) ;
644- Some ( self . dlsym_proc_macros ( tcx, & dlsym_dylib. 0 , dlsym_root. stable_crate_id ( ) ) ?)
646+ Some ( self . dlsym_proc_macros ( tcx. sess , & dlsym_dylib. 0 , dlsym_root. stable_crate_id ( ) ) ?)
645647 } else {
646648 None
647649 } ;
@@ -665,24 +667,24 @@ impl CStore {
665667 Ok ( cnum)
666668 }
667669
668- fn load_proc_macro < ' b , ' tcx > (
670+ fn load_proc_macro < ' a , ' b > (
669671 & self ,
670- tcx : TyCtxt < ' tcx > ,
672+ sess : & ' a Session ,
671673 locator : & mut CrateLocator < ' b > ,
672674 crate_rejections : & mut CrateRejections ,
673675 path_kind : PathKind ,
674676 host_hash : Option < Svh > ,
675677 ) -> Result < Option < ( LoadResult , Option < Library > ) > , CrateError >
676678 where
677- ' tcx : ' b ,
679+ ' a : ' b ,
678680 {
679- if tcx . sess . opts . unstable_opts . dual_proc_macros {
681+ if sess. opts . unstable_opts . dual_proc_macros {
680682 // Use a new crate locator and crate rejections so trying to load a proc macro doesn't
681683 // affect the error message we emit
682684 let mut proc_macro_locator = locator. clone ( ) ;
683685
684686 // Try to load a proc macro
685- proc_macro_locator. for_target_proc_macro ( tcx . sess , path_kind) ;
687+ proc_macro_locator. for_target_proc_macro ( sess, path_kind) ;
686688
687689 // Load the proc macro crate for the target
688690 let target_result =
@@ -699,7 +701,7 @@ impl CStore {
699701 * crate_rejections = CrateRejections :: default ( ) ;
700702
701703 // Load the proc macro crate for the host
702- locator. for_proc_macro ( tcx . sess , path_kind) ;
704+ locator. for_proc_macro ( sess, path_kind) ;
703705
704706 locator. hash = host_hash;
705707
@@ -720,7 +722,7 @@ impl CStore {
720722 let mut proc_macro_locator = locator. clone ( ) ;
721723
722724 // Load the proc macro crate for the host
723- proc_macro_locator. for_proc_macro ( tcx . sess , path_kind) ;
725+ proc_macro_locator. for_proc_macro ( sess, path_kind) ;
724726
725727 let Some ( host_result) =
726728 self . load ( & mut proc_macro_locator, & mut CrateRejections :: default ( ) ) ?
@@ -782,7 +784,9 @@ impl CStore {
782784 let path_kind = if dep. is_some ( ) { PathKind :: Dependency } else { PathKind :: Crate } ;
783785 let private_dep = origin. private_dep ( ) ;
784786
785- let result = if let Some ( cnum) = self . existing_match ( tcx, name, hash, path_kind) {
787+ let result = if let Some ( cnum) =
788+ self . existing_match ( & tcx. sess . opts . externs , name, hash, path_kind)
789+ {
786790 ( LoadResult :: Previous ( cnum) , None )
787791 } else {
788792 info ! ( "falling back to a load" ) ;
@@ -805,7 +809,7 @@ impl CStore {
805809 info ! ( "falling back to loading proc_macro" ) ;
806810 dep_kind = CrateDepKind :: MacrosOnly ;
807811 match self . load_proc_macro (
808- tcx,
812+ tcx. sess ,
809813 & mut locator,
810814 & mut crate_rejections,
811815 path_kind,
@@ -825,7 +829,8 @@ impl CStore {
825829 // not specified by `--extern` on command line parameters, it may be
826830 // `private-dependency` when `register_crate` is called for the first time. Then it must be updated to
827831 // `public-dependency` here.
828- let private_dep = self . is_private_dep ( tcx, name, private_dep, origin) ;
832+ let private_dep =
833+ self . is_private_dep ( & tcx. sess . opts . externs , name, private_dep, origin) ;
829834 let data = self . get_crate_data_mut ( cnum) ;
830835 if data. is_proc_macro_crate ( ) {
831836 dep_kind = CrateDepKind :: MacrosOnly ;
@@ -924,13 +929,13 @@ impl CStore {
924929 Ok ( crate_num_map)
925930 }
926931
927- fn dlsym_proc_macros < ' tcx > (
932+ fn dlsym_proc_macros (
928933 & self ,
929- tcx : TyCtxt < ' tcx > ,
934+ sess : & Session ,
930935 path : & Path ,
931936 stable_crate_id : StableCrateId ,
932937 ) -> Result < & ' static [ ProcMacro ] , CrateError > {
933- let sym_name = tcx . sess . generate_proc_macro_decls_symbol ( stable_crate_id) ;
938+ let sym_name = sess. generate_proc_macro_decls_symbol ( stable_crate_id) ;
934939 debug ! ( "trying to dlsym proc_macros {} for symbol `{}`" , path. display( ) , sym_name) ;
935940
936941 unsafe {
0 commit comments