fix(resolve): skip assertion judgment when NonModule
is dummy
This commit is contained in:
parent
e013d8f8b3
commit
549f48d0ed
7 changed files with 32 additions and 4 deletions
|
@ -370,7 +370,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
/// expansion and import resolution (perhaps they can be merged in the future).
|
/// expansion and import resolution (perhaps they can be merged in the future).
|
||||||
/// The function is used for resolving initial segments of macro paths (e.g., `foo` in
|
/// The function is used for resolving initial segments of macro paths (e.g., `foo` in
|
||||||
/// `foo::bar!();` or `foo!();`) and also for import paths on 2018 edition.
|
/// `foo::bar!();` or `foo!();`) and also for import paths on 2018 edition.
|
||||||
#[instrument(level = "debug", skip(self, scope_set))]
|
#[instrument(level = "debug", skip(self))]
|
||||||
pub(crate) fn early_resolve_ident_in_lexical_scope(
|
pub(crate) fn early_resolve_ident_in_lexical_scope(
|
||||||
&mut self,
|
&mut self,
|
||||||
orig_ident: Ident,
|
orig_ident: Ident,
|
||||||
|
|
|
@ -894,8 +894,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
PathResult::NonModule(_) => {
|
PathResult::NonModule(partial_res) => {
|
||||||
if no_ambiguity {
|
if no_ambiguity && partial_res.full_res() != Some(Res::Err) {
|
||||||
|
// Check if there are no ambiguities and the result is not dummy.
|
||||||
assert!(import.imported_module.get().is_none());
|
assert!(import.imported_module.get().is_none());
|
||||||
}
|
}
|
||||||
// The error was already reported earlier.
|
// The error was already reported earlier.
|
||||||
|
|
|
@ -128,7 +128,7 @@ enum Scope<'a> {
|
||||||
/// with different restrictions when looking up the resolution.
|
/// with different restrictions when looking up the resolution.
|
||||||
/// This enum is currently used only for early resolution (imports and macros),
|
/// This enum is currently used only for early resolution (imports and macros),
|
||||||
/// but not for late resolution yet.
|
/// but not for late resolution yet.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum ScopeSet<'a> {
|
enum ScopeSet<'a> {
|
||||||
/// All scopes with the given namespace.
|
/// All scopes with the given namespace.
|
||||||
All(Namespace),
|
All(Namespace),
|
||||||
|
|
6
tests/ui/imports/auxiliary/issue-85992-extern-1.rs
Normal file
6
tests/ui/imports/auxiliary/issue-85992-extern-1.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! m {
|
||||||
|
() => {
|
||||||
|
use issue_85992_extern_2::Outcome;
|
||||||
|
}
|
||||||
|
}
|
1
tests/ui/imports/auxiliary/issue-85992-extern-2.rs
Normal file
1
tests/ui/imports/auxiliary/issue-85992-extern-2.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
// nothing
|
11
tests/ui/imports/issue-85992.rs
Normal file
11
tests/ui/imports/issue-85992.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// edition: 2021
|
||||||
|
// compile-flags: --extern issue_85992_extern_1 --extern issue_85992_extern_2
|
||||||
|
// aux-build: issue-85992-extern-1.rs
|
||||||
|
// aux-build: issue-85992-extern-2.rs
|
||||||
|
|
||||||
|
issue_85992_extern_1::m!();
|
||||||
|
|
||||||
|
use crate::issue_85992_extern_2;
|
||||||
|
//~^ ERROR unresolved import `crate::issue_85992_extern_2`
|
||||||
|
|
||||||
|
fn main() {}
|
9
tests/ui/imports/issue-85992.stderr
Normal file
9
tests/ui/imports/issue-85992.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0432]: unresolved import `crate::issue_85992_extern_2`
|
||||||
|
--> $DIR/issue-85992.rs:8:5
|
||||||
|
|
|
||||||
|
LL | use crate::issue_85992_extern_2;
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `issue_85992_extern_2` in the root
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
Loading…
Add table
Add a link
Reference in a new issue