Skip to content

Commit 85d2cf3

Browse files
Rollup merge of #151268 - ice-inconsistent-resolution-151213, r=mati865
Fix ICE on inconsistent import resolution with macro-attributed extern crate Fixes #151213 using issue_145575_hack_applied in the same way as in #149860.
2 parents a5b6c4b + 4d2f6a0 commit 85d2cf3

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

compiler/rustc_resolve/src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
989989
PathResult::Module(module) => {
990990
// Consistency checks, analogous to `finalize_macro_resolutions`.
991991
if let Some(initial_module) = import.imported_module.get() {
992-
if module != initial_module && no_ambiguity {
992+
if module != initial_module && no_ambiguity && !self.issue_145575_hack_applied {
993993
span_bug!(import.span, "inconsistent resolution for an import");
994994
}
995995
} else if self.privacy_errors.is_empty() {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ edition: 2024
2+
3+
#[attr]
4+
//~^ ERROR cannot find attribute `attr` in this scope
5+
extern crate core as std;
6+
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
7+
8+
mod inner {
9+
use std::str;
10+
11+
use crate::*;
12+
}
13+
14+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
2+
--> $DIR/ice-inconsistent-resolution-151213.rs:5:1
3+
|
4+
LL | extern crate core as std;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: cannot find attribute `attr` in this scope
8+
--> $DIR/ice-inconsistent-resolution-151213.rs:3:3
9+
|
10+
LL | #[attr]
11+
| ^^^^
12+
13+
error: aborting due to 2 previous errors
14+

0 commit comments

Comments
 (0)