mark binding undetermined if target name exist and not obtained
This commit is contained in:
parent
1be24d70ce
commit
93feaa6685
@ -998,14 +998,14 @@ fn resolve_ident_in_module_unadjusted_ext(
|
|||||||
let Some(module) = single_import.imported_module.get() else {
|
let Some(module) = single_import.imported_module.get() else {
|
||||||
return Err((Undetermined, Weak::No));
|
return Err((Undetermined, Weak::No));
|
||||||
};
|
};
|
||||||
let ImportKind::Single { source: ident, source_bindings, .. } = &single_import.kind
|
let ImportKind::Single { source: ident, target, target_bindings, .. } =
|
||||||
|
&single_import.kind
|
||||||
else {
|
else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
if binding.map_or(false, |binding| binding.module().is_some())
|
if (ident != target) && target_bindings.iter().all(|binding| binding.get().is_none()) {
|
||||||
&& source_bindings.iter().all(|binding| matches!(binding.get(), Err(Undetermined)))
|
// This branch allows the binding to be defined or updated later if the target name
|
||||||
{
|
// can hide the source but these bindings are not obtained.
|
||||||
// This branch allows the binding to be defined or updated later,
|
|
||||||
// avoiding module inconsistency between the resolve process and the finalize process.
|
// avoiding module inconsistency between the resolve process and the finalize process.
|
||||||
// See more details in #124840
|
// See more details in #124840
|
||||||
return Err((Undetermined, Weak::No));
|
return Err((Undetermined, Weak::No));
|
||||||
|
9
tests/ui/imports/cycle-import-in-std-1.rs
Normal file
9
tests/ui/imports/cycle-import-in-std-1.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//@ edition: 2018
|
||||||
|
|
||||||
|
// https://github.com/rust-lang/rust/issues/124490
|
||||||
|
|
||||||
|
use ops::{self as std};
|
||||||
|
//~^ ERROR: unresolved import `ops`
|
||||||
|
use std::collections::{self as ops};
|
||||||
|
|
||||||
|
fn main() {}
|
13
tests/ui/imports/cycle-import-in-std-1.stderr
Normal file
13
tests/ui/imports/cycle-import-in-std-1.stderr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
error[E0432]: unresolved import `ops`
|
||||||
|
--> $DIR/cycle-import-in-std-1.rs:5:11
|
||||||
|
|
|
||||||
|
LL | use ops::{self as std};
|
||||||
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
||||||
|
= help: consider importing one of these items instead:
|
||||||
|
core::ops
|
||||||
|
std::ops
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
9
tests/ui/imports/cycle-import-in-std-2.rs
Normal file
9
tests/ui/imports/cycle-import-in-std-2.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
//@ edition: 2018
|
||||||
|
|
||||||
|
// https://github.com/rust-lang/rust/issues/125013
|
||||||
|
|
||||||
|
use ops::{self as std};
|
||||||
|
//~^ ERROR: unresolved import `ops`
|
||||||
|
use std::ops::Deref::{self as ops};
|
||||||
|
|
||||||
|
fn main() {}
|
13
tests/ui/imports/cycle-import-in-std-2.stderr
Normal file
13
tests/ui/imports/cycle-import-in-std-2.stderr
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
error[E0432]: unresolved import `ops`
|
||||||
|
--> $DIR/cycle-import-in-std-2.rs:5:11
|
||||||
|
|
|
||||||
|
LL | use ops::{self as std};
|
||||||
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
||||||
|
= help: consider importing one of these items instead:
|
||||||
|
core::ops
|
||||||
|
std::ops
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0432`.
|
Loading…
Reference in New Issue
Block a user