Rollup merge of #120850 - petrochenkov:empimpres, r=cjgillot

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

Fixes https://github.com/rust-lang/rust/issues/120789
This commit is contained in:
Matthias Krüger 2024-02-10 00:58:39 +01:00 committed by GitHub
commit 8177c0fead
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 // For empty lists we need to lower the prefix so it is checked for things
// like stability later. // like stability later.
let res = self.lower_import_res(id, span); 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() {}