Skip to content

Commit 2af1d6f

Browse files
committed
resolve: Fix another ICE in import validation
1 parent 3cda631 commit 2af1d6f

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

src/librustc_resolve/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1014,11 +1014,11 @@ enum ModuleOrUniformRoot<'a> {
10141014
CurrentScope,
10151015
}
10161016

1017-
impl<'a> PartialEq for ModuleOrUniformRoot<'a> {
1018-
fn eq(&self, other: &Self) -> bool {
1019-
match (*self, *other) {
1017+
impl ModuleOrUniformRoot<'_> {
1018+
fn same_def(lhs: Self, rhs: Self) -> bool {
1019+
match (lhs, rhs) {
10201020
(ModuleOrUniformRoot::Module(lhs),
1021-
ModuleOrUniformRoot::Module(rhs)) => ptr::eq(lhs, rhs),
1021+
ModuleOrUniformRoot::Module(rhs)) => lhs.def() == rhs.def(),
10221022
(ModuleOrUniformRoot::CrateRootAndExternPrelude,
10231023
ModuleOrUniformRoot::CrateRootAndExternPrelude) |
10241024
(ModuleOrUniformRoot::ExternPrelude, ModuleOrUniformRoot::ExternPrelude) |

src/librustc_resolve/resolve_imports.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
842842
PathResult::Module(module) => {
843843
// Consistency checks, analogous to `finalize_current_module_macro_resolutions`.
844844
if let Some(initial_module) = directive.imported_module.get() {
845-
if module != initial_module && no_ambiguity {
845+
if !ModuleOrUniformRoot::same_def(module, initial_module) && no_ambiguity {
846846
span_bug!(directive.span, "inconsistent resolution for an import");
847847
}
848848
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub extern crate core;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// compile-pass
2+
// edition:2018
3+
// compile-flags: --extern issue_56596_2
4+
// aux-build:issue-56596-2.rs
5+
6+
mod m {
7+
use core::any;
8+
pub use issue_56596_2::*;
9+
}
10+
11+
fn main() {}

0 commit comments

Comments
 (0)