@@ -21,7 +21,7 @@ use rustc_session::config::{self, CrateType, ExternLocation};
21
21
use rustc_session:: lint:: { self , BuiltinLintDiagnostics , ExternDepSpec } ;
22
22
use rustc_session:: output:: validate_crate_name;
23
23
use rustc_session:: search_paths:: PathKind ;
24
- use rustc_session:: Session ;
24
+ use rustc_session:: { CrateDisambiguator , Session } ;
25
25
use rustc_span:: edition:: Edition ;
26
26
use rustc_span:: symbol:: { sym, Symbol } ;
27
27
use rustc_span:: { Span , DUMMY_SP } ;
@@ -222,8 +222,10 @@ impl<'a> CrateLoader<'a> {
222
222
metadata_loader : & ' a MetadataLoaderDyn ,
223
223
local_crate_name : & str ,
224
224
) -> Self {
225
+ let local_crate_stable_id =
226
+ StableCrateId :: new ( local_crate_name, sess. local_crate_disambiguator ( ) ) ;
225
227
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 ) ;
227
229
228
230
CrateLoader {
229
231
sess,
@@ -325,14 +327,17 @@ impl<'a> CrateLoader<'a> {
325
327
326
328
fn verify_no_symbol_conflicts ( & self , root : & CrateRoot < ' _ > ) -> Result < ( ) , CrateError > {
327
329
// 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
+ {
329
333
return Err ( CrateError :: SymbolConflictsCurrent ( root. name ( ) ) ) ;
330
334
}
331
335
332
336
// Check for conflicts with any crate loaded so far
333
337
let mut res = Ok ( ( ) ) ;
334
338
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
336
341
other. hash ( ) != root. hash ( )
337
342
{
338
343
// but different SVH
@@ -406,7 +411,7 @@ impl<'a> CrateLoader<'a> {
406
411
None => ( & source, & crate_root) ,
407
412
} ;
408
413
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 ( ) ) ?)
410
415
} else {
411
416
None
412
417
} ;
@@ -659,7 +664,7 @@ impl<'a> CrateLoader<'a> {
659
664
fn dlsym_proc_macros (
660
665
& self ,
661
666
path : & Path ,
662
- stable_crate_id : StableCrateId ,
667
+ disambiguator : CrateDisambiguator ,
663
668
) -> Result < & ' static [ ProcMacro ] , CrateError > {
664
669
// Make sure the path contains a / or the linker will search for it.
665
670
let path = env:: current_dir ( ) . unwrap ( ) . join ( path) ;
@@ -668,7 +673,7 @@ impl<'a> CrateLoader<'a> {
668
673
Err ( s) => return Err ( CrateError :: DlOpen ( s) ) ,
669
674
} ;
670
675
671
- let sym = self . sess . generate_proc_macro_decls_symbol ( stable_crate_id ) ;
676
+ let sym = self . sess . generate_proc_macro_decls_symbol ( disambiguator ) ;
672
677
let decls = unsafe {
673
678
let sym = match lib. symbol ( & sym) {
674
679
Ok ( f) => f,
0 commit comments