X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_metadata%2Fsrc%2Fcreader.rs;h=e9ae22f8cedbc47926fd0ed4aa39e9ae0469fa10;hb=e062121f036e632a2d4a698270dbf3accae919ee;hp=42c32219aba417e4c2b8826c58a0b4ad3aed2187;hpb=153f22a90699d7af1a129e34b8a46eaec247f641;p=rust.git diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 42c32219aba..e9ae22f8ced 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -21,7 +21,7 @@ use rustc_session::lint::{self, BuiltinLintDiagnostics, ExternDepSpec}; use rustc_session::output::validate_crate_name; use rustc_session::search_paths::PathKind; -use rustc_session::Session; +use rustc_session::{CrateDisambiguator, Session}; use rustc_span::edition::Edition; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; @@ -222,8 +222,10 @@ pub fn new( metadata_loader: &'a MetadataLoaderDyn, local_crate_name: &str, ) -> Self { + let local_crate_stable_id = + StableCrateId::new(local_crate_name, sess.local_crate_disambiguator()); let mut stable_crate_ids = FxHashMap::default(); - stable_crate_ids.insert(sess.local_stable_crate_id(), LOCAL_CRATE); + stable_crate_ids.insert(local_crate_stable_id, LOCAL_CRATE); CrateLoader { sess, @@ -325,14 +327,17 @@ fn existing_match(&self, name: Symbol, hash: Option, kind: PathKind) -> Opt fn verify_no_symbol_conflicts(&self, root: &CrateRoot<'_>) -> Result<(), CrateError> { // Check for (potential) conflicts with the local crate - if self.sess.local_stable_crate_id() == root.stable_crate_id() { + if self.local_crate_name == root.name() + && self.sess.local_crate_disambiguator() == root.disambiguator() + { return Err(CrateError::SymbolConflictsCurrent(root.name())); } // Check for conflicts with any crate loaded so far let mut res = Ok(()); self.cstore.iter_crate_data(|_, other| { - if other.stable_crate_id() == root.stable_crate_id() && // same stable crate id + if other.name() == root.name() && // same crate-name + other.disambiguator() == root.disambiguator() && // same crate-disambiguator other.hash() != root.hash() { // but different SVH @@ -406,7 +411,7 @@ fn register_crate( None => (&source, &crate_root), }; let dlsym_dylib = dlsym_source.dylib.as_ref().expect("no dylib for a proc-macro crate"); - Some(self.dlsym_proc_macros(&dlsym_dylib.0, dlsym_root.stable_crate_id())?) + Some(self.dlsym_proc_macros(&dlsym_dylib.0, dlsym_root.disambiguator())?) } else { None }; @@ -659,7 +664,7 @@ fn resolve_crate_deps( fn dlsym_proc_macros( &self, path: &Path, - stable_crate_id: StableCrateId, + disambiguator: CrateDisambiguator, ) -> Result<&'static [ProcMacro], CrateError> { // Make sure the path contains a / or the linker will search for it. let path = env::current_dir().unwrap().join(path); @@ -668,7 +673,7 @@ fn dlsym_proc_macros( Err(s) => return Err(CrateError::DlOpen(s)), }; - let sym = self.sess.generate_proc_macro_decls_symbol(stable_crate_id); + let sym = self.sess.generate_proc_macro_decls_symbol(disambiguator); let decls = unsafe { let sym = match lib.symbol(&sym) { Ok(f) => f,