Skip to content

Commit 57009e7

Browse files
petrochenkovpietroalbini
authored andcommitted
resolve: Fix another ICE in import validation
1 parent f493744 commit 57009e7

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/librustc_resolve/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,11 +1022,11 @@ enum ModuleOrUniformRoot<'a> {
10221022
CurrentScope,
10231023
}
10241024

1025-
impl<'a> PartialEq for ModuleOrUniformRoot<'a> {
1026-
fn eq(&self, other: &Self) -> bool {
1027-
match (*self, *other) {
1025+
impl ModuleOrUniformRoot<'_> {
1026+
fn same_def(lhs: Self, rhs: Self) -> bool {
1027+
match (lhs, rhs) {
10281028
(ModuleOrUniformRoot::Module(lhs),
1029-
ModuleOrUniformRoot::Module(rhs)) => ptr::eq(lhs, rhs),
1029+
ModuleOrUniformRoot::Module(rhs)) => lhs.def() == rhs.def(),
10301030
(ModuleOrUniformRoot::CrateRootAndExternPrelude,
10311031
ModuleOrUniformRoot::CrateRootAndExternPrelude) |
10321032
(ModuleOrUniformRoot::ExternPrelude, ModuleOrUniformRoot::ExternPrelude) |

src/librustc_resolve/resolve_imports.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,9 @@ impl<'a, 'b:'a, 'c: 'b> ImportResolver<'a, 'b, 'c> {
836836
PathResult::Module(module) => {
837837
// Consistency checks, analogous to `finalize_current_module_macro_resolutions`.
838838
if let Some(initial_module) = directive.imported_module.get() {
839-
if module != initial_module && self.ambiguity_errors.is_empty() {
839+
if !ModuleOrUniformRoot::same_def(module, initial_module)
840+
&& self.ambiguity_errors.is_empty()
841+
{
840842
span_bug!(directive.span, "inconsistent resolution for an import");
841843
}
842844
} else {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub extern crate core;
Lines changed: 11 additions & 0 deletions
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)