rustc_ast_lowering: Stop lowering imports into multiple items
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
This commit is contained in:
parent
1f259ae679
commit
b32a4edb20
25 changed files with 79 additions and 198 deletions
|
@ -2517,10 +2517,7 @@ pub struct Variant {
|
|||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub enum UseTreeKind {
|
||||
/// `use prefix` or `use prefix as rename`
|
||||
///
|
||||
/// The extra `NodeId`s are for HIR lowering, when additional statements are created for each
|
||||
/// namespace.
|
||||
Simple(Option<Ident>, NodeId, NodeId),
|
||||
Simple(Option<Ident>),
|
||||
/// `use prefix::{...}`
|
||||
Nested(Vec<(UseTree, NodeId)>),
|
||||
/// `use prefix::*`
|
||||
|
@ -2539,8 +2536,8 @@ pub struct UseTree {
|
|||
impl UseTree {
|
||||
pub fn ident(&self) -> Ident {
|
||||
match self.kind {
|
||||
UseTreeKind::Simple(Some(rename), ..) => rename,
|
||||
UseTreeKind::Simple(None, ..) => {
|
||||
UseTreeKind::Simple(Some(rename)) => rename,
|
||||
UseTreeKind::Simple(None) => {
|
||||
self.prefix.segments.last().expect("empty prefix in a simple import").ident
|
||||
}
|
||||
_ => panic!("`UseTree::ident` can only be used on a simple import"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue