Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
ast_lowering: Fix regression in use ::{} imports.
  • Loading branch information
petrochenkov committed Feb 9, 2024
commit 8b6b9c5efc6635a75bcd15899bc4314483c8e836
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() {}