Revert "Merge CrateDisambiguator into StableCrateId"
This reverts commit d0ec85d3fb
.
This commit is contained in:
parent
6c5b6985fd
commit
8176ab8bc1
30 changed files with 207 additions and 127 deletions
|
@ -21,7 +21,7 @@ use rustc_session::config::{self, CrateType, ExternLocation};
|
|||
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 @@ impl<'a> CrateLoader<'a> {
|
|||
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 @@ impl<'a> CrateLoader<'a> {
|
|||
|
||||
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 @@ impl<'a> CrateLoader<'a> {
|
|||
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 @@ impl<'a> CrateLoader<'a> {
|
|||
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 @@ impl<'a> CrateLoader<'a> {
|
|||
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,
|
||||
|
|
|
@ -226,7 +226,7 @@ use rustc_session::config::{self, CrateType};
|
|||
use rustc_session::filesearch::{FileDoesntMatch, FileMatches, FileSearch};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_session::utils::CanonicalizedPath;
|
||||
use rustc_session::{Session, StableCrateId};
|
||||
use rustc_session::{CrateDisambiguator, Session};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::spec::{Target, TargetTriple};
|
||||
|
@ -787,7 +787,7 @@ pub fn find_plugin_registrar(
|
|||
metadata_loader: &dyn MetadataLoader,
|
||||
span: Span,
|
||||
name: Symbol,
|
||||
) -> (PathBuf, StableCrateId) {
|
||||
) -> (PathBuf, CrateDisambiguator) {
|
||||
match find_plugin_registrar_impl(sess, metadata_loader, name) {
|
||||
Ok(res) => res,
|
||||
// `core` is always available if we got as far as loading plugins.
|
||||
|
@ -799,7 +799,7 @@ fn find_plugin_registrar_impl<'a>(
|
|||
sess: &'a Session,
|
||||
metadata_loader: &dyn MetadataLoader,
|
||||
name: Symbol,
|
||||
) -> Result<(PathBuf, StableCrateId), CrateError> {
|
||||
) -> Result<(PathBuf, CrateDisambiguator), CrateError> {
|
||||
info!("find plugin registrar `{}`", name);
|
||||
let mut locator = CrateLocator::new(
|
||||
sess,
|
||||
|
@ -816,7 +816,7 @@ fn find_plugin_registrar_impl<'a>(
|
|||
|
||||
match locator.maybe_load_library_crate()? {
|
||||
Some(library) => match library.source.dylib {
|
||||
Some(dylib) => Ok((dylib.0, library.metadata.get_root().stable_crate_id())),
|
||||
Some(dylib) => Ok((dylib.0, library.metadata.get_root().disambiguator())),
|
||||
None => Err(CrateError::NonDylibPlugin(name)),
|
||||
},
|
||||
None => Err(locator.into_error()),
|
||||
|
|
|
@ -620,6 +620,10 @@ impl CrateRoot<'_> {
|
|||
self.name
|
||||
}
|
||||
|
||||
crate fn disambiguator(&self) -> CrateDisambiguator {
|
||||
self.disambiguator
|
||||
}
|
||||
|
||||
crate fn hash(&self) -> Svh {
|
||||
self.hash
|
||||
}
|
||||
|
@ -1923,8 +1927,8 @@ impl CrateMetadata {
|
|||
self.root.name
|
||||
}
|
||||
|
||||
crate fn stable_crate_id(&self) -> StableCrateId {
|
||||
self.root.stable_crate_id
|
||||
crate fn disambiguator(&self) -> CrateDisambiguator {
|
||||
self.root.disambiguator
|
||||
}
|
||||
|
||||
crate fn hash(&self) -> Svh {
|
||||
|
|
|
@ -19,7 +19,7 @@ use rustc_middle::middle::stability::DeprecationEntry;
|
|||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, TyCtxt, Visibility};
|
||||
use rustc_session::utils::NativeLibKind;
|
||||
use rustc_session::{Session, StableCrateId};
|
||||
use rustc_session::{CrateDisambiguator, Session};
|
||||
use rustc_span::source_map::{Span, Spanned};
|
||||
use rustc_span::symbol::Symbol;
|
||||
|
||||
|
@ -186,6 +186,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
}
|
||||
native_libraries => { Lrc::new(cdata.get_native_libraries(tcx.sess)) }
|
||||
foreign_modules => { cdata.get_foreign_modules(tcx) }
|
||||
crate_disambiguator => { cdata.root.disambiguator }
|
||||
crate_hash => { cdata.root.hash }
|
||||
crate_host_hash => { cdata.host_hash }
|
||||
crate_name => { cdata.root.name }
|
||||
|
@ -488,8 +489,8 @@ impl CrateStore for CStore {
|
|||
self.get_crate_data(cnum).root.name
|
||||
}
|
||||
|
||||
fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId {
|
||||
self.get_crate_data(cnum).root.stable_crate_id
|
||||
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator {
|
||||
self.get_crate_data(cnum).root.disambiguator
|
||||
}
|
||||
|
||||
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh {
|
||||
|
|
|
@ -671,6 +671,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
extra_filename: tcx.sess.opts.cg.extra_filename.clone(),
|
||||
triple: tcx.sess.opts.target_triple.clone(),
|
||||
hash: tcx.crate_hash(LOCAL_CRATE),
|
||||
disambiguator: tcx.sess.local_crate_disambiguator(),
|
||||
stable_crate_id: tcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(),
|
||||
panic_strategy: tcx.sess.panic_strategy(),
|
||||
edition: tcx.sess.edition(),
|
||||
|
|
|
@ -18,6 +18,7 @@ use rustc_middle::mir;
|
|||
use rustc_middle::ty::{self, ReprOptions, Ty};
|
||||
use rustc_serialize::opaque::Encoder;
|
||||
use rustc_session::config::SymbolManglingVersion;
|
||||
use rustc_session::CrateDisambiguator;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
|
@ -201,6 +202,7 @@ crate struct CrateRoot<'tcx> {
|
|||
triple: TargetTriple,
|
||||
extra_filename: String,
|
||||
hash: Svh,
|
||||
disambiguator: CrateDisambiguator,
|
||||
stable_crate_id: StableCrateId,
|
||||
panic_strategy: PanicStrategy,
|
||||
edition: Edition,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue