@@ -21,7 +21,7 @@ use rustc_session::config::{self, CrateType, ExternLocation};
2121use rustc_session:: lint:: { self , BuiltinLintDiagnostics , ExternDepSpec } ;
2222use rustc_session:: output:: validate_crate_name;
2323use rustc_session:: search_paths:: PathKind ;
24- use rustc_session:: Session ;
24+ use rustc_session:: { CrateDisambiguator , Session } ;
2525use rustc_span:: edition:: Edition ;
2626use rustc_span:: symbol:: { sym, Symbol } ;
2727use rustc_span:: { Span , DUMMY_SP } ;
@@ -222,8 +222,10 @@ impl<'a> CrateLoader<'a> {
222222 metadata_loader : & ' a MetadataLoaderDyn ,
223223 local_crate_name : & str ,
224224 ) -> Self {
225+ let local_crate_stable_id =
226+ StableCrateId :: new ( local_crate_name, sess. local_crate_disambiguator ( ) ) ;
225227 let mut stable_crate_ids = FxHashMap :: default ( ) ;
226- stable_crate_ids. insert ( sess . local_stable_crate_id ( ) , LOCAL_CRATE ) ;
228+ stable_crate_ids. insert ( local_crate_stable_id , LOCAL_CRATE ) ;
227229
228230 CrateLoader {
229231 sess,
@@ -325,14 +327,17 @@ impl<'a> CrateLoader<'a> {
325327
326328 fn verify_no_symbol_conflicts ( & self , root : & CrateRoot < ' _ > ) -> Result < ( ) , CrateError > {
327329 // Check for (potential) conflicts with the local crate
328- if self . sess . local_stable_crate_id ( ) == root. stable_crate_id ( ) {
330+ if self . local_crate_name == root. name ( )
331+ && self . sess . local_crate_disambiguator ( ) == root. disambiguator ( )
332+ {
329333 return Err ( CrateError :: SymbolConflictsCurrent ( root. name ( ) ) ) ;
330334 }
331335
332336 // Check for conflicts with any crate loaded so far
333337 let mut res = Ok ( ( ) ) ;
334338 self . cstore . iter_crate_data ( |_, other| {
335- if other. stable_crate_id ( ) == root. stable_crate_id ( ) && // same stable crate id
339+ if other. name ( ) == root. name ( ) && // same crate-name
340+ other. disambiguator ( ) == root. disambiguator ( ) && // same crate-disambiguator
336341 other. hash ( ) != root. hash ( )
337342 {
338343 // but different SVH
@@ -406,7 +411,7 @@ impl<'a> CrateLoader<'a> {
406411 None => ( & source, & crate_root) ,
407412 } ;
408413 let dlsym_dylib = dlsym_source. dylib . as_ref ( ) . expect ( "no dylib for a proc-macro crate" ) ;
409- Some ( self . dlsym_proc_macros ( & dlsym_dylib. 0 , dlsym_root. stable_crate_id ( ) ) ?)
414+ Some ( self . dlsym_proc_macros ( & dlsym_dylib. 0 , dlsym_root. disambiguator ( ) ) ?)
410415 } else {
411416 None
412417 } ;
@@ -659,7 +664,7 @@ impl<'a> CrateLoader<'a> {
659664 fn dlsym_proc_macros (
660665 & self ,
661666 path : & Path ,
662- stable_crate_id : StableCrateId ,
667+ disambiguator : CrateDisambiguator ,
663668 ) -> Result < & ' static [ ProcMacro ] , CrateError > {
664669 // Make sure the path contains a / or the linker will search for it.
665670 let path = env:: current_dir ( ) . unwrap ( ) . join ( path) ;
@@ -668,7 +673,7 @@ impl<'a> CrateLoader<'a> {
668673 Err ( s) => return Err ( CrateError :: DlOpen ( s) ) ,
669674 } ;
670675
671- let sym = self . sess . generate_proc_macro_decls_symbol ( stable_crate_id ) ;
676+ let sym = self . sess . generate_proc_macro_decls_symbol ( disambiguator ) ;
672677 let decls = unsafe {
673678 let sym = match lib. symbol ( & sym) {
674679 Ok ( f) => f,
0 commit comments