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

This commit is contained in:
Vadim Petrochenkov 2024-02-09 19:52:41 +03:00
parent 8fb67fb37f
commit 8b6b9c5efc
3 changed files with 26 additions and 1 deletions

View File

@ -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);

View File

@ -0,0 +1,10 @@
// check-pass
// edition:2015
use {};
use {{}};
use ::{};
use {::{}};
fn main() {}

View File

@ -0,0 +1,10 @@
// check-pass
// edition:2018
use {};
use {{}};
use ::{};
use {::{}};
fn main() {}