Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast_lowering: Fix regression in use ::{} imports. #120850

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
});
}

let path = if trees.is_empty() && !prefix.segments.is_empty() {
// Condition should match `build_reduced_graph_for_use_tree`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The segment types are, unfortunately, different between here and resolve, so it cannot be just shared.

let path = if trees.is_empty()
&& !(prefix.segments.is_empty()
|| prefix.segments.len() == 1
&& prefix.segments[0].ident.name == kw::PathRoot)
{
// For empty lists we need to lower the prefix so it is checked for things
// like stability later.
let res = self.lower_import_res(id, span);
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/imports/empty-import-prefix-pass-2015.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass
// edition:2015

use {};
use {{}};

use ::{};
use {::{}};

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/imports/empty-import-prefix-pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// check-pass
// edition:2018

use {};
use {{}};

use ::{};
use {::{}};

fn main() {}
Loading