Skip to content

Commit 4bca296

Browse files
authored
Rollup merge of rust-lang#126065 - bvanjoi:fix-124490, r=petrochenkov
mark binding undetermined if target name exist and not obtained - Fixes rust-lang#124490 - Fixes rust-lang#125013 Following up on rust-lang#124840, I think handling only `target_bindings` is sufficient. r? `@petrochenkov`
2 parents 1f715eb + 93feaa6 commit 4bca296

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

compiler/rustc_resolve/src/ident.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -998,14 +998,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
998998
let Some(module) = single_import.imported_module.get() else {
999999
return Err((Undetermined, Weak::No));
10001000
};
1001-
let ImportKind::Single { source: ident, source_bindings, .. } = &single_import.kind
1001+
let ImportKind::Single { source: ident, target, target_bindings, .. } =
1002+
&single_import.kind
10021003
else {
10031004
unreachable!();
10041005
};
1005-
if binding.map_or(false, |binding| binding.module().is_some())
1006-
&& source_bindings.iter().all(|binding| matches!(binding.get(), Err(Undetermined)))
1007-
{
1008-
// This branch allows the binding to be defined or updated later,
1006+
if (ident != target) && target_bindings.iter().all(|binding| binding.get().is_none()) {
1007+
// This branch allows the binding to be defined or updated later if the target name
1008+
// can hide the source but these bindings are not obtained.
10091009
// avoiding module inconsistency between the resolve process and the finalize process.
10101010
// See more details in #124840
10111011
return Err((Undetermined, Weak::No));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ edition: 2018
2+
3+
// https://github.com/rust-lang/rust/issues/124490
4+
5+
use ops::{self as std};
6+
//~^ ERROR: unresolved import `ops`
7+
use std::collections::{self as ops};
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0432]: unresolved import `ops`
2+
--> $DIR/cycle-import-in-std-1.rs:5:11
3+
|
4+
LL | use ops::{self as std};
5+
| ^^^^^^^^^^^ no external crate `ops`
6+
|
7+
= help: consider importing one of these items instead:
8+
core::ops
9+
std::ops
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0432`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ edition: 2018
2+
3+
// https://github.com/rust-lang/rust/issues/125013
4+
5+
use ops::{self as std};
6+
//~^ ERROR: unresolved import `ops`
7+
use std::ops::Deref::{self as ops};
8+
9+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0432]: unresolved import `ops`
2+
--> $DIR/cycle-import-in-std-2.rs:5:11
3+
|
4+
LL | use ops::{self as std};
5+
| ^^^^^^^^^^^ no external crate `ops`
6+
|
7+
= help: consider importing one of these items instead:
8+
core::ops
9+
std::ops
10+
11+
error: aborting due to 1 previous error
12+
13+
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)