Skip to content

Commit a577b1c

Browse files
committed
round 1
1 parent 5b8817f commit a577b1c

File tree

27 files changed

+476
-395
lines changed

27 files changed

+476
-395
lines changed

compiler/rustc_ast/src/ast.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3003,10 +3003,11 @@ pub struct Fn {
30033003

30043004
#[derive(Clone, Encodable, Decodable, Debug)]
30053005
pub struct Delegation {
3006+
/// Path resolution id.
30063007
pub id: NodeId,
3007-
pub path: (Option<P<QSelf>>, Path),
3008-
pub target_expr: Option<P<Expr>>,
3009-
pub span: Span,
3008+
pub qself: Option<P<QSelf>>,
3009+
pub path: Path,
3010+
pub body: Option<P<Block>>,
30103011
}
30113012

30123013
#[derive(Clone, Encodable, Decodable, Debug)]
@@ -3131,7 +3132,7 @@ impl ItemKind {
31313132
ItemKind::MacCall(..) => "item macro invocation",
31323133
ItemKind::MacroDef(..) => "macro definition",
31333134
ItemKind::Impl { .. } => "implementation",
3134-
ItemKind::Delegation(..) => "delegation",
3135+
ItemKind::Delegation(..) => "delegated function",
31353136
}
31363137
}
31373138

compiler/rustc_ast/src/ast_traits.rs

+3-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::ptr::P;
66
use crate::token::Nonterminal;
77
use crate::tokenstream::LazyAttrTokenStream;
8-
use crate::{Arm, Crate, Delegation, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
8+
use crate::{Arm, Crate, ExprField, FieldDef, GenericParam, Param, PatField, Variant};
99
use crate::{AssocItem, Expr, ForeignItem, Item, NodeId};
1010
use crate::{AttrItem, AttrKind, Block, Pat, Path, Ty, Visibility};
1111
use crate::{AttrVec, Attribute, Stmt, StmtKind};
@@ -80,7 +80,6 @@ impl_has_node_id!(
8080
Stmt,
8181
Ty,
8282
Variant,
83-
Delegation
8483
);
8584

8685
impl<T: AstDeref<Target: HasNodeId>> HasNodeId for T {
@@ -109,19 +108,7 @@ macro_rules! impl_has_span {
109108
};
110109
}
111110

112-
impl_has_span!(
113-
AssocItem,
114-
Block,
115-
Expr,
116-
ForeignItem,
117-
Item,
118-
Pat,
119-
Path,
120-
Stmt,
121-
Ty,
122-
Visibility,
123-
Delegation
124-
);
111+
impl_has_span!(AssocItem, Block, Expr, ForeignItem, Item, Pat, Path, Stmt, Ty, Visibility);
125112

126113
impl<T: AstDeref<Target: HasSpan>> HasSpan for T {
127114
fn span(&self) -> Span {
@@ -172,7 +159,7 @@ macro_rules! impl_has_tokens_none {
172159
}
173160

174161
impl_has_tokens!(AssocItem, AttrItem, Block, Expr, ForeignItem, Item, Pat, Path, Ty, Visibility);
175-
impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant, Delegation);
162+
impl_has_tokens_none!(Arm, ExprField, FieldDef, GenericParam, Param, PatField, Variant);
176163

177164
impl<T: AstDeref<Target: HasTokens>> HasTokens for T {
178165
fn tokens(&self) -> Option<&LazyAttrTokenStream> {

compiler/rustc_ast/src/mut_visit.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1119,10 +1119,10 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
11191119
ItemKind::MacroDef(def) => vis.visit_macro_def(def),
11201120
ItemKind::Delegation(box delegation) => {
11211121
vis.visit_id(&mut delegation.id);
1122-
vis.visit_qself(&mut delegation.path.0);
1123-
vis.visit_path(&mut delegation.path.1);
1124-
if let Some(target_expr) = &mut delegation.target_expr {
1125-
vis.visit_expr(target_expr);
1122+
vis.visit_qself(&mut delegation.qself);
1123+
vis.visit_path(&mut delegation.path);
1124+
if let Some(body) = &mut delegation.body {
1125+
vis.visit_block(body);
11261126
}
11271127
}
11281128
}
@@ -1165,10 +1165,10 @@ pub fn noop_flat_map_assoc_item<T: MutVisitor>(
11651165
AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
11661166
AssocItemKind::Delegation(box delegation) => {
11671167
visitor.visit_id(&mut delegation.id);
1168-
visitor.visit_qself(&mut delegation.path.0);
1169-
visitor.visit_path(&mut delegation.path.1);
1170-
if let Some(target_expr) = &mut delegation.target_expr {
1171-
visitor.visit_expr(target_expr);
1168+
visitor.visit_qself(&mut delegation.qself);
1169+
visitor.visit_path(&mut delegation.path);
1170+
if let Some(body) = &mut delegation.body {
1171+
visitor.visit_block(body);
11721172
}
11731173
}
11741174
}

compiler/rustc_ast/src/visit.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
376376
ItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
377377
ItemKind::MacroDef(ts) => visitor.visit_mac_def(ts, item.id),
378378
ItemKind::Delegation(box delegation) => {
379-
if let Some(qself) = &delegation.path.0 {
379+
if let Some(qself) = &delegation.qself {
380380
visitor.visit_ty(&qself.ty);
381381
}
382-
walk_path(visitor, &delegation.path.1);
383-
if let Some(target_expr) = &delegation.target_expr {
384-
visitor.visit_expr(target_expr);
382+
walk_path(visitor, &delegation.path);
383+
if let Some(body) = &delegation.body {
384+
visitor.visit_block(body);
385385
}
386386
}
387387
}
@@ -714,12 +714,12 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem,
714714
visitor.visit_mac_call(mac);
715715
}
716716
AssocItemKind::Delegation(box delegation) => {
717-
if let Some(qself) = &delegation.path.0 {
717+
if let Some(qself) = &delegation.qself {
718718
visitor.visit_ty(&qself.ty);
719719
}
720-
walk_path(visitor, &delegation.path.1);
721-
if let Some(target_expr) = &delegation.target_expr {
722-
visitor.visit_expr(target_expr);
720+
walk_path(visitor, &delegation.path);
721+
if let Some(body) = &delegation.body {
722+
visitor.visit_block(body);
723723
}
724724
}
725725
}

0 commit comments

Comments
 (0)