Skip to content

Commit 9348af8

Browse files
committed
Add NodeId for Arm, Field and FieldPat
1 parent 60960a2 commit 9348af8

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

src/libsyntax/ast.rs

+3
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ pub struct FieldPat {
608608
pub pat: P<Pat>,
609609
pub is_shorthand: bool,
610610
pub attrs: ThinVec<Attribute>,
611+
pub id: NodeId,
611612
}
612613

613614
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
@@ -925,6 +926,7 @@ pub struct Arm {
925926
pub guard: Option<P<Expr>>,
926927
pub body: P<Expr>,
927928
pub span: Span,
929+
pub id: NodeId,
928930
}
929931

930932
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
@@ -934,6 +936,7 @@ pub struct Field {
934936
pub span: Span,
935937
pub is_shorthand: bool,
936938
pub attrs: ThinVec<Attribute>,
939+
pub id: NodeId,
937940
}
938941

939942
pub type SpannedIdent = Spanned<Ident>;

src/libsyntax/ext/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ impl<'a> ExtCtxt<'a> {
403403
span,
404404
is_shorthand: false,
405405
attrs: ThinVec::new(),
406+
id: ast::DUMMY_NODE_ID,
406407
}
407408
}
408409
pub fn expr_struct(
@@ -612,6 +613,7 @@ impl<'a> ExtCtxt<'a> {
612613
guard: None,
613614
body: expr,
614615
span,
616+
id: ast::DUMMY_NODE_ID,
615617
}
616618
}
617619

src/libsyntax/mut_visit.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,11 @@ pub fn noop_visit_use_tree<T: MutVisitor>(use_tree: &mut UseTree, vis: &mut T) {
383383
}
384384

385385
pub fn noop_visit_arm<T: MutVisitor>(
386-
Arm { attrs, pats, guard, body, span }: &mut Arm,
386+
Arm { attrs, pats, guard, body, span, id }: &mut Arm,
387387
vis: &mut T,
388388
) {
389389
visit_attrs(attrs, vis);
390+
vis.visit_id(id);
390391
visit_vec(pats, |pat| vis.visit_pat(pat));
391392
visit_opt(guard, |guard| vis.visit_expr(guard));
392393
vis.visit_expr(body);
@@ -808,9 +809,10 @@ pub fn noop_visit_struct_field<T: MutVisitor>(f: &mut StructField, visitor: &mut
808809
}
809810

810811
pub fn noop_visit_field<T: MutVisitor>(f: &mut Field, vis: &mut T) {
811-
let Field { ident, expr, span, is_shorthand: _, attrs } = f;
812+
let Field { ident, expr, span, is_shorthand: _, attrs, id } = f;
812813
vis.visit_ident(ident);
813814
vis.visit_expr(expr);
815+
vis.visit_id(id);
814816
vis.visit_span(span);
815817
visit_thin_attrs(attrs, vis);
816818
}
@@ -1040,8 +1042,12 @@ pub fn noop_visit_pat<T: MutVisitor>(pat: &mut P<Pat>, vis: &mut T) {
10401042
}
10411043
PatKind::Struct(path, fields, _etc) => {
10421044
vis.visit_path(path);
1043-
for Spanned { node: FieldPat { ident, pat, is_shorthand: _, attrs }, span } in fields {
1045+
for Spanned {
1046+
node: FieldPat { ident, pat, is_shorthand: _, attrs, id },
1047+
span
1048+
} in fields {
10441049
vis.visit_ident(ident);
1050+
vis.visit_id(id);
10451051
vis.visit_pat(pat);
10461052
visit_thin_attrs(attrs, vis);
10471053
vis.visit_span(span);

src/libsyntax/parse/parser/expr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,7 @@ impl<'a> Parser<'a> {
14441444
guard,
14451445
body: expr,
14461446
span: lo.to(hi),
1447+
id: ast::DUMMY_NODE_ID,
14471448
})
14481449
}
14491450

@@ -1599,6 +1600,7 @@ impl<'a> Parser<'a> {
15991600
expr: self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()),
16001601
is_shorthand: false,
16011602
attrs: ThinVec::new(),
1603+
id: ast::DUMMY_NODE_ID,
16021604
});
16031605
}
16041606
}
@@ -1684,6 +1686,7 @@ impl<'a> Parser<'a> {
16841686
expr,
16851687
is_shorthand,
16861688
attrs: attrs.into(),
1689+
id: ast::DUMMY_NODE_ID,
16871690
})
16881691
}
16891692

src/libsyntax/parse/parser/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ impl<'a> Parser<'a> {
620620
pat: subpat,
621621
is_shorthand,
622622
attrs: attrs.into(),
623+
id: ast::DUMMY_NODE_ID,
623624
}
624625
})
625626
}

src/libsyntax_ext/deriving/generic/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ impl<'a> TraitDef<'a> {
16131613
source_map::Spanned {
16141614
span: pat.span.with_ctxt(self.span.ctxt()),
16151615
node: ast::FieldPat {
1616+
id: ast::DUMMY_NODE_ID,
16161617
ident: ident.unwrap(),
16171618
pat,
16181619
is_shorthand: false,

0 commit comments

Comments
 (0)