Auto merge of #123413 - petrochenkov:delegmulti2, r=fmease · rust-lang/rust@3cb0030
@@ -2961,6 +2961,7 @@ impl Item {
29612961 | ItemKind::GlobalAsm(_)
29622962 | ItemKind::MacCall(_)
29632963 | ItemKind::Delegation(_)
2964+ | ItemKind::DelegationMac(_)
29642965 | ItemKind::MacroDef(_) => None,
29652966ItemKind::Static(_) => None,
29662967ItemKind::Const(i) => Some(&i.generics),
@@ -3123,8 +3124,16 @@ pub struct Delegation {
31233124/// Path resolution id.
31243125 pub id: NodeId,
31253126pub qself: Option<P<QSelf>>,
3126-pub rename: Option<Ident>,
31273127pub path: Path,
3128+pub rename: Option<Ident>,
3129+pub body: Option<P<Block>>,
3130+}
3131+3132+#[derive(Clone, Encodable, Decodable, Debug)]
3133+pub struct DelegationMac {
3134+pub qself: Option<P<QSelf>>,
3135+pub prefix: Path,
3136+pub suffixes: ThinVec<(Ident, Option<Ident>)>,
31283137pub body: Option<P<Block>>,
31293138}
31303139@@ -3243,10 +3252,13 @@ pub enum ItemKind {
32433252/// A macro definition.
32443253 MacroDef(MacroDef),
324532543246-/// A delegation item (`reuse`).
3255+/// A single delegation item (`reuse`).
32473256 ///
32483257 /// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
32493258 Delegation(Box<Delegation>),
3259+/// A list delegation item (`reuse prefix::{a, b, c}`).
3260+ /// Treated similarly to a macro call and expanded early.
3261+ DelegationMac(Box<DelegationMac>),
32503262}
3251326332523264impl ItemKind {
@@ -3255,7 +3267,7 @@ impl ItemKind {
32553267match self {
32563268Use(..) | Static(..) | Const(..) | Fn(..) | Mod(..) | GlobalAsm(..) | TyAlias(..)
32573269 | Struct(..) | Union(..) | Trait(..) | TraitAlias(..) | MacroDef(..)
3258- | Delegation(..) => "a",
3270+ | Delegation(..) | DelegationMac(..) => "a",
32593271ExternCrate(..) | ForeignMod(..) | MacCall(..) | Enum(..) | Impl { .. } => "an",
32603272}
32613273}
@@ -3280,6 +3292,7 @@ impl ItemKind {
32803292ItemKind::MacroDef(..) => "macro definition",
32813293ItemKind::Impl { .. } => "implementation",
32823294ItemKind::Delegation(..) => "delegated function",
3295+ItemKind::DelegationMac(..) => "delegation",
32833296}
32843297}
32853298@@ -3323,6 +3336,8 @@ pub enum AssocItemKind {
33233336 MacCall(P<MacCall>),
33243337/// An associated delegation item.
33253338 Delegation(Box<Delegation>),
3339+/// An associated delegation item list.
3340+ DelegationMac(Box<DelegationMac>),
33263341}
3327334233283343impl AssocItemKind {
@@ -3331,7 +3346,9 @@ impl AssocItemKind {
33313346Self::Const(box ConstItem { defaultness, .. })
33323347 | Self::Fn(box Fn { defaultness, .. })
33333348 | Self::Type(box TyAlias { defaultness, .. }) => defaultness,
3334-Self::MacCall(..) | Self::Delegation(..) => Defaultness::Final,
3349+Self::MacCall(..) | Self::Delegation(..) | Self::DelegationMac(..) => {
3350+Defaultness::Final
3351+}
33353352}
33363353}
33373354}
@@ -3344,6 +3361,7 @@ impl From<AssocItemKind> for ItemKind {
33443361AssocItemKind::Type(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
33453362AssocItemKind::MacCall(a) => ItemKind::MacCall(a),
33463363AssocItemKind::Delegation(delegation) => ItemKind::Delegation(delegation),
3364+AssocItemKind::DelegationMac(delegation) => ItemKind::DelegationMac(delegation),
33473365}
33483366}
33493367}
@@ -3358,6 +3376,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
33583376ItemKind::TyAlias(ty_kind) => AssocItemKind::Type(ty_kind),
33593377ItemKind::MacCall(a) => AssocItemKind::MacCall(a),
33603378ItemKind::Delegation(d) => AssocItemKind::Delegation(d),
3379+ItemKind::DelegationMac(d) => AssocItemKind::DelegationMac(d),
33613380 _ => return Err(item_kind),
33623381})
33633382}