Rollup merge of #111461 - oli-obk:crate_collision, r=petrochenkov
Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic This was a refactoring mistake in https://github.com/rust-lang/rust/pull/109213 fixes #111284
This commit is contained in:
commit
731c1a5592
@ -148,11 +148,15 @@ fn intern_stable_crate_id(&mut self, root: &CrateRoot) -> Result<CrateNum, Crate
|
||||
assert_eq!(self.metas.len(), self.stable_crate_ids.len());
|
||||
let num = CrateNum::new(self.stable_crate_ids.len());
|
||||
if let Some(&existing) = self.stable_crate_ids.get(&root.stable_crate_id()) {
|
||||
let crate_name0 = root.name();
|
||||
if let Some(crate_name1) = self.metas[existing].as_ref().map(|data| data.name()) {
|
||||
// Check for (potential) conflicts with the local crate
|
||||
if existing == LOCAL_CRATE {
|
||||
Err(CrateError::SymbolConflictsCurrent(root.name()))
|
||||
} else if let Some(crate_name1) = self.metas[existing].as_ref().map(|data| data.name())
|
||||
{
|
||||
let crate_name0 = root.name();
|
||||
Err(CrateError::StableCrateIdCollision(crate_name0, crate_name1))
|
||||
} else {
|
||||
Err(CrateError::SymbolConflictsCurrent(crate_name0))
|
||||
Err(CrateError::NotFound(root.name()))
|
||||
}
|
||||
} else {
|
||||
self.metas.push(None);
|
||||
|
@ -961,6 +961,7 @@ pub(crate) enum CrateError {
|
||||
DlSym(String),
|
||||
LocatorCombined(Box<CombinedLocatorError>),
|
||||
NonDylibPlugin(Symbol),
|
||||
NotFound(Symbol),
|
||||
}
|
||||
|
||||
enum MetadataError<'a> {
|
||||
@ -1131,6 +1132,18 @@ pub(crate) fn report(self, sess: &Session, span: Span, missing_core: bool) {
|
||||
CrateError::NonDylibPlugin(crate_name) => {
|
||||
sess.emit_err(errors::NoDylibPlugin { span, crate_name });
|
||||
}
|
||||
CrateError::NotFound(crate_name) => {
|
||||
sess.emit_err(errors::CannotFindCrate {
|
||||
span,
|
||||
crate_name,
|
||||
add_info: String::new(),
|
||||
missing_core,
|
||||
current_crate: sess.opts.crate_name.clone().unwrap_or("<unknown>".to_string()),
|
||||
is_nightly_build: sess.is_nightly_build(),
|
||||
profiler_runtime: Symbol::intern(&sess.opts.unstable_opts.profiler_runtime),
|
||||
locator_triple: sess.opts.target_triple.clone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,5 +29,5 @@ all:
|
||||
--crate-type=rlib \
|
||||
--edition=2018 \
|
||||
c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0
|
||||
$(CGREP) E0519 < $(TMPDIR)/output.txt
|
||||
$(CGREP) E0463 < $(TMPDIR)/output.txt
|
||||
$(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt
|
||||
|
Loading…
Reference in New Issue
Block a user