Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
822c320
remove legacy rustsrc folder
lqd May 28, 2024
f027366
document DIST_TRY_BUILD
lqd May 28, 2024
7cd732f
Avoid `mut` and simplify initialization of `TASK_QUEUE`
raoulstrackx May 29, 2024
c3de4b3
Handle all GVN binops in a single place.
cjgillot Jun 2, 2024
f4b060e
Add more ABI test cases.
Lokathor May 28, 2024
f67a0eb
resolve: mark it undetermined if single import is not has any bindings
bvanjoi Jun 4, 2024
9b2e41a
Pass function for `Thread` as `Send` to `Thread::imp`
raoulstrackx May 30, 2024
b8c6008
Store `Task::p` as `dyn FnOnce() + Send`
raoulstrackx May 30, 2024
8db363c
Let compiler auto impl `Send` for `Task`
raoulstrackx May 30, 2024
5e8df95
Manual rustfmt
oli-obk May 27, 2024
14f9c63
Show that it will pick up the entirely wrong function as a private ca…
oli-obk May 28, 2024
7d151fa
Turn a delayed bug back into a normal bug by winnowing private method…
oli-obk May 27, 2024
7894a11
Move tests to a more appropriate directory
oli-obk May 28, 2024
8189506
Give test a more useful name
oli-obk May 28, 2024
ffb1b2c
Add test description
oli-obk May 28, 2024
8746703
Orphanck: Consider opaque types to never cover type parameters
fmease Jun 1, 2024
54b2e86
Port `tests/run-make-fulldeps/issue-19371` to ui-fulldeps
Zalathar Jun 5, 2024
b710404
Update the interpreter to handle the new cases
saethlin Jun 4, 2024
e704858
Update description of the `IsTerminal` example
ChrisDenton Jun 5, 2024
69a8c13
Rollup merge of #124840 - bvanjoi:fix-124490, r=petrochenkov
matthiaskrgr Jun 5, 2024
9abf8b1
Rollup merge of #125622 - oli-obk:define_opaque_types15, r=compiler-e…
matthiaskrgr Jun 5, 2024
edba401
Rollup merge of #125648 - lqd:rustsrc, r=pietroalbini
matthiaskrgr Jun 5, 2024
36cab12
Rollup merge of #125672 - Lokathor:update-miri-result-ffi, r=RalfJung
matthiaskrgr Jun 5, 2024
fcc0b64
Rollup merge of #125800 - fortanix:raoul/rte-99-fix_mut_static_task_q…
matthiaskrgr Jun 5, 2024
9c8e46d
Rollup merge of #125871 - fmease:fix-orphanck-opaques, r=lcnr
matthiaskrgr Jun 5, 2024
33c02c3
Rollup merge of #125893 - cjgillot:gvn-newops, r=oli-obk
matthiaskrgr Jun 5, 2024
1c17449
Rollup merge of #126008 - Zalathar:fulldeps-19371, r=jieyouxu
matthiaskrgr Jun 5, 2024
fa58891
Rollup merge of #126032 - ChrisDenton:update-docs, r=joboet
matthiaskrgr Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
resolve: mark it undetermined if single import is not has any bindings
  • Loading branch information
bvanjoi committed Jun 4, 2024
commit f67a0eb2b72294f108051381cbc833c295aadad9
29 changes: 27 additions & 2 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// if it can then our result is not determined and can be invalidated.
for single_import in &resolution.single_imports {
let Some(import_vis) = single_import.vis.get() else {
// This branch handles a cycle in single imports, which occurs
// when we've previously captured the `vis` value during an import
// process.
//
// For example:
// ```
// use a::b;
// use b as a;
// ```
// 1. Steal the `vis` in `use a::b` and attempt to locate `a` in the
// current module.
// 2. Encounter the import `use b as a`, which is a `single_import` for `a`,
// and try to find `b` in the current module.
// 3. Re-encounter the `use a::b` import since it's a `single_import` of `b`.
// This leads to entering this branch.
continue;
};
if !self.is_accessible_from(import_vis, parent_scope.module) {
Expand All @@ -979,15 +994,25 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// named imports.
continue;
}

let Some(module) = single_import.imported_module.get() else {
return Err((Undetermined, Weak::No));
};
let ImportKind::Single { source: ident, .. } = single_import.kind else {
let ImportKind::Single { source: ident, source_bindings, .. } = &single_import.kind
else {
unreachable!();
};
if binding.map_or(false, |binding| binding.module().is_some())
&& source_bindings.iter().all(|binding| matches!(binding.get(), Err(Undetermined)))
{
// This branch allows the binding to be defined or updated later,
// avoiding module inconsistency between the resolve process and the finalize process.
// See more details in #124840
return Err((Undetermined, Weak::No));
}
match self.resolve_ident_in_module(
module,
ident,
*ident,
ns,
&single_import.parent_scope,
None,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
(old_glob @ true, false) | (old_glob @ false, true) => {
let (glob_binding, nonglob_binding) =
if old_glob { (old_binding, binding) } else { (binding, old_binding) };
if glob_binding.res() != nonglob_binding.res()
&& key.ns == MacroNS
if key.ns == MacroNS
&& nonglob_binding.expansion != LocalExpnId::ROOT
&& glob_binding.res() != nonglob_binding.res()
{
resolution.binding = Some(this.ambiguity(
AmbiguityKind::GlobVsExpanded,
Expand Down
16 changes: 0 additions & 16 deletions tests/crashes/124490.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/crashes/125013-1.rs

This file was deleted.

16 changes: 0 additions & 16 deletions tests/crashes/125013-2.rs

This file was deleted.

14 changes: 14 additions & 0 deletions tests/ui/imports/cycle-import-in-diff-module-0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ check-pass

// https://github.com/rust-lang/rust/pull/124840#issuecomment-2098148587

mod a {
pub(crate) use crate::S;
}
mod b {
pub struct S;
}
use self::a::S;
use self::b::*;

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/imports/cycle-import-in-diff-module-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ check-pass

// similar `cycle-import-in-diff-module-0.rs`

mod a {
pub(crate) use crate::s;
}
mod b {
pub mod s {}
}
use self::b::*;
use self::a::s;

fn main() {}
17 changes: 17 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://github.com/rust-lang/rust/issues/124490

mod a {
pub mod b {
pub mod c {}
}
}

use a::*;

use b::c;
//~^ ERROR: cannot determine resolution for the import
//~| ERROR: cannot determine resolution for the import
//~| ERROR: unresolved import `b::c`
use c as b;

fn main() {}
23 changes: 23 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: cannot determine resolution for the import
--> $DIR/shadow-glob-module-resolution-1.rs:11:5
|
LL | use b::c;
| ^^^^

error: cannot determine resolution for the import
--> $DIR/shadow-glob-module-resolution-1.rs:11:5
|
LL | use b::c;
| ^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0432]: unresolved import `b::c`
--> $DIR/shadow-glob-module-resolution-1.rs:11:5
|
LL | use b::c;
| ^^^^

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0432`.
19 changes: 19 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://github.com/rust-lang/rust/issues/125013

mod a {
pub mod b {
pub mod c {
pub trait D {}
}
}
}

use a::*;

use e as b;
//~^ ERROR: unresolved import `e`
use b::c::D as e;
//~^ ERROR: cannot determine resolution for the import
//~| ERROR: cannot determine resolution for the import

fn main() { }
26 changes: 26 additions & 0 deletions tests/ui/imports/shadow-glob-module-resolution-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
error: cannot determine resolution for the import
--> $DIR/shadow-glob-module-resolution-2.rs:15:5
|
LL | use b::c::D as e;
| ^^^^^^^^^^^^

error: cannot determine resolution for the import
--> $DIR/shadow-glob-module-resolution-2.rs:15:5
|
LL | use b::c::D as e;
| ^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0432]: unresolved import `e`
--> $DIR/shadow-glob-module-resolution-2.rs:13:5
|
LL | use e as b;
| -^^^^^
| |
| no `e` in the root
| help: a similar name exists in the module: `a`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0432`.