Skip to content

Commit c7cb67b

Browse files
authored
Rollup merge of rust-lang#63542 - c410-f3r:node_ids, r=petrochenkov
Add NodeId for Arm, Field and FieldPat Extracted from rust-lang#63468
2 parents 76d02b3 + 9348af8 commit c7cb67b

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
@@ -1448,6 +1448,7 @@ impl<'a> Parser<'a> {
14481448
guard,
14491449
body: expr,
14501450
span: lo.to(hi),
1451+
id: ast::DUMMY_NODE_ID,
14511452
})
14521453
}
14531454

@@ -1603,6 +1604,7 @@ impl<'a> Parser<'a> {
16031604
expr: self.mk_expr(self.token.span, ExprKind::Err, ThinVec::new()),
16041605
is_shorthand: false,
16051606
attrs: ThinVec::new(),
1607+
id: ast::DUMMY_NODE_ID,
16061608
});
16071609
}
16081610
}
@@ -1688,6 +1690,7 @@ impl<'a> Parser<'a> {
16881690
expr,
16891691
is_shorthand,
16901692
attrs: attrs.into(),
1693+
id: ast::DUMMY_NODE_ID,
16911694
})
16921695
}
16931696

src/libsyntax/parse/parser/pat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ impl<'a> Parser<'a> {
665665
pat: subpat,
666666
is_shorthand,
667667
attrs: attrs.into(),
668+
id: ast::DUMMY_NODE_ID,
668669
}
669670
})
670671
}

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)