Skip to content

Commit 9e5639e

Browse files
authored
Rollup merge of rust-lang#120850 - petrochenkov:empimpres, r=cjgillot
ast_lowering: Fix regression in `use ::{}` imports. Fixes rust-lang#120789
2 parents dadff64 + 8b6b9c5 commit 9e5639e

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

compiler/rustc_ast_lowering/src/item.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
569569
});
570570
}
571571

572-
let path = if trees.is_empty() && !prefix.segments.is_empty() {
572+
// Condition should match `build_reduced_graph_for_use_tree`.
573+
let path = if trees.is_empty()
574+
&& !(prefix.segments.is_empty()
575+
|| prefix.segments.len() == 1
576+
&& prefix.segments[0].ident.name == kw::PathRoot)
577+
{
573578
// For empty lists we need to lower the prefix so it is checked for things
574579
// like stability later.
575580
let res = self.lower_import_res(id, span);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// edition:2015
3+
4+
use {};
5+
use {{}};
6+
7+
use ::{};
8+
use {::{}};
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// edition:2018
3+
4+
use {};
5+
use {{}};
6+
7+
use ::{};
8+
use {::{}};
9+
10+
fn main() {}

0 commit comments

Comments
 (0)