Skip to content

Commit

Permalink
Rollup merge of #120850 - petrochenkov:empimpres, r=cjgillot
Browse files Browse the repository at this point in the history
ast_lowering: Fix regression in `use ::{}` imports.

Fixes #120789
  • Loading branch information
matthiaskrgr authored Feb 9, 2024
2 parents 317c372 + 8b6b9c5 commit 8177c0f
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 8177c0f

Please sign in to comment.