Skip to content

Commit 549f48d

Browse files
committed
fix(resolve): skip assertion judgment when NonModule is dummy
1 parent e013d8f commit 549f48d

File tree

7 files changed

+32
-4
lines changed

7 files changed

+32
-4
lines changed

compiler/rustc_resolve/src/ident.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
370370
/// expansion and import resolution (perhaps they can be merged in the future).
371371
/// The function is used for resolving initial segments of macro paths (e.g., `foo` in
372372
/// `foo::bar!();` or `foo!();`) and also for import paths on 2018 edition.
373-
#[instrument(level = "debug", skip(self, scope_set))]
373+
#[instrument(level = "debug", skip(self))]
374374
pub(crate) fn early_resolve_ident_in_lexical_scope(
375375
&mut self,
376376
orig_ident: Ident,

compiler/rustc_resolve/src/imports.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
894894
}
895895
return None;
896896
}
897-
PathResult::NonModule(_) => {
898-
if no_ambiguity {
897+
PathResult::NonModule(partial_res) => {
898+
if no_ambiguity && partial_res.full_res() != Some(Res::Err) {
899+
// Check if there are no ambiguities and the result is not dummy.
899900
assert!(import.imported_module.get().is_none());
900901
}
901902
// The error was already reported earlier.

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ enum Scope<'a> {
128128
/// with different restrictions when looking up the resolution.
129129
/// This enum is currently used only for early resolution (imports and macros),
130130
/// but not for late resolution yet.
131-
#[derive(Clone, Copy)]
131+
#[derive(Clone, Copy, Debug)]
132132
enum ScopeSet<'a> {
133133
/// All scopes with the given namespace.
134134
All(Namespace),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[macro_export]
2+
macro_rules! m {
3+
() => {
4+
use issue_85992_extern_2::Outcome;
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// nothing

tests/ui/imports/issue-85992.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// edition: 2021
2+
// compile-flags: --extern issue_85992_extern_1 --extern issue_85992_extern_2
3+
// aux-build: issue-85992-extern-1.rs
4+
// aux-build: issue-85992-extern-2.rs
5+
6+
issue_85992_extern_1::m!();
7+
8+
use crate::issue_85992_extern_2;
9+
//~^ ERROR unresolved import `crate::issue_85992_extern_2`
10+
11+
fn main() {}

tests/ui/imports/issue-85992.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0432]: unresolved import `crate::issue_85992_extern_2`
2+
--> $DIR/issue-85992.rs:8:5
3+
|
4+
LL | use crate::issue_85992_extern_2;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `issue_85992_extern_2` in the root
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)