Skip to content

Commit

Permalink
ast_lowering: Fix regression in use ::{} imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Feb 9, 2024
1 parent 8fb67fb commit 8b6b9c5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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`.
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() {}

0 comments on commit 8b6b9c5

Please sign in to comment.