Skip to content

Commit 731c1a5

Browse files
authored
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 #109213 fixes #111284
2 parents cda5bec + 6d1a1cf commit 731c1a5

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

compiler/rustc_metadata/src/creader.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ impl CStore {
148148
assert_eq!(self.metas.len(), self.stable_crate_ids.len());
149149
let num = CrateNum::new(self.stable_crate_ids.len());
150150
if let Some(&existing) = self.stable_crate_ids.get(&root.stable_crate_id()) {
151-
let crate_name0 = root.name();
152-
if let Some(crate_name1) = self.metas[existing].as_ref().map(|data| data.name()) {
151+
// Check for (potential) conflicts with the local crate
152+
if existing == LOCAL_CRATE {
153+
Err(CrateError::SymbolConflictsCurrent(root.name()))
154+
} else if let Some(crate_name1) = self.metas[existing].as_ref().map(|data| data.name())
155+
{
156+
let crate_name0 = root.name();
153157
Err(CrateError::StableCrateIdCollision(crate_name0, crate_name1))
154158
} else {
155-
Err(CrateError::SymbolConflictsCurrent(crate_name0))
159+
Err(CrateError::NotFound(root.name()))
156160
}
157161
} else {
158162
self.metas.push(None);

compiler/rustc_metadata/src/locator.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ pub(crate) enum CrateError {
961961
DlSym(String),
962962
LocatorCombined(Box<CombinedLocatorError>),
963963
NonDylibPlugin(Symbol),
964+
NotFound(Symbol),
964965
}
965966

966967
enum MetadataError<'a> {
@@ -1131,6 +1132,18 @@ impl CrateError {
11311132
CrateError::NonDylibPlugin(crate_name) => {
11321133
sess.emit_err(errors::NoDylibPlugin { span, crate_name });
11331134
}
1135+
CrateError::NotFound(crate_name) => {
1136+
sess.emit_err(errors::CannotFindCrate {
1137+
span,
1138+
crate_name,
1139+
add_info: String::new(),
1140+
missing_core,
1141+
current_crate: sess.opts.crate_name.clone().unwrap_or("<unknown>".to_string()),
1142+
is_nightly_build: sess.is_nightly_build(),
1143+
profiler_runtime: Symbol::intern(&sess.opts.unstable_opts.profiler_runtime),
1144+
locator_triple: sess.opts.target_triple.clone(),
1145+
});
1146+
}
11341147
}
11351148
}
11361149
}

tests/run-make/issue-83045/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ all:
2929
--crate-type=rlib \
3030
--edition=2018 \
3131
c.rs 2>&1 | tee $(TMPDIR)/output.txt || exit 0
32-
$(CGREP) E0519 < $(TMPDIR)/output.txt
32+
$(CGREP) E0463 < $(TMPDIR)/output.txt
3333
$(CGREP) -v "internal compiler error" < $(TMPDIR)/output.txt

0 commit comments

Comments
 (0)