Skip to content

Commit e189a6a

Browse files
committed
ast: Add tokens to Expr
1 parent 2835ca6 commit e189a6a

File tree

11 files changed

+23
-5
lines changed

11 files changed

+23
-5
lines changed

src/librustc_ast/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,12 @@ pub struct Expr {
10111011
pub kind: ExprKind,
10121012
pub span: Span,
10131013
pub attrs: AttrVec,
1014+
pub tokens: Option<TokenStream>,
10141015
}
10151016

10161017
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
10171018
#[cfg(target_arch = "x86_64")]
1018-
rustc_data_structures::static_assert_size!(Expr, 96);
1019+
rustc_data_structures::static_assert_size!(Expr, 104);
10191020

10201021
impl Expr {
10211022
/// Returns `true` if this expression would be valid somewhere that expects a value;

src/librustc_ast/mut_visit.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,10 @@ pub fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonCo
10921092
vis.visit_expr(value);
10931093
}
10941094

1095-
pub fn noop_visit_expr<T: MutVisitor>(Expr { kind, id, span, attrs }: &mut Expr, vis: &mut T) {
1095+
pub fn noop_visit_expr<T: MutVisitor>(
1096+
Expr { kind, id, span, attrs, tokens: _ }: &mut Expr,
1097+
vis: &mut T,
1098+
) {
10961099
match kind {
10971100
ExprKind::Box(expr) => vis.visit_expr(expr),
10981101
ExprKind::Array(exprs) => visit_exprs(exprs, vis),

src/librustc_ast_lowering/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11291129
kind: ExprKind::Path(qself.clone(), path.clone()),
11301130
span: ty.span,
11311131
attrs: AttrVec::new(),
1132+
tokens: None,
11321133
};
11331134

11341135
let ct = self.with_new_scopes(|this| hir::AnonConst {

src/librustc_builtin_macros/asm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub fn expand_asm<'cx>(
6161
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
6262
span: cx.with_def_site_ctxt(sp),
6363
attrs: ast::AttrVec::new(),
64+
tokens: None,
6465
}))
6566
}
6667

src/librustc_builtin_macros/concat_idents.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pub fn expand_concat_idents<'cx>(
5252
kind: ast::ExprKind::Path(None, ast::Path::from_ident(self.ident)),
5353
span: self.ident.span,
5454
attrs: ast::AttrVec::new(),
55+
tokens: None,
5556
}))
5657
}
5758

src/librustc_expand/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ impl DummyResult {
583583
kind: if is_error { ast::ExprKind::Err } else { ast::ExprKind::Tup(Vec::new()) },
584584
span: sp,
585585
attrs: ast::AttrVec::new(),
586+
tokens: None,
586587
})
587588
}
588589

src/librustc_expand/build.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ impl<'a> ExtCtxt<'a> {
6969
pub fn anon_const(&self, span: Span, kind: ast::ExprKind) -> ast::AnonConst {
7070
ast::AnonConst {
7171
id: ast::DUMMY_NODE_ID,
72-
value: P(ast::Expr { id: ast::DUMMY_NODE_ID, kind, span, attrs: AttrVec::new() }),
72+
value: P(ast::Expr {
73+
id: ast::DUMMY_NODE_ID,
74+
kind,
75+
span,
76+
attrs: AttrVec::new(),
77+
tokens: None,
78+
}),
7379
}
7480
}
7581

@@ -210,7 +216,7 @@ impl<'a> ExtCtxt<'a> {
210216
}
211217

212218
pub fn expr(&self, span: Span, kind: ast::ExprKind) -> P<ast::Expr> {
213-
P(ast::Expr { id: ast::DUMMY_NODE_ID, kind, span, attrs: AttrVec::new() })
219+
P(ast::Expr { id: ast::DUMMY_NODE_ID, kind, span, attrs: AttrVec::new(), tokens: None })
214220
}
215221

216222
pub fn expr_path(&self, path: ast::Path) -> P<ast::Expr> {

src/librustc_expand/placeholders.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub fn placeholder(
3333
span,
3434
attrs: ast::AttrVec::new(),
3535
kind: ast::ExprKind::MacCall(mac_placeholder()),
36+
tokens: None,
3637
})
3738
};
3839
let ty = || P(ast::Ty { id, kind: ast::TyKind::MacCall(mac_placeholder()), span });

src/librustc_interface/util.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
719719
kind: ast::ExprKind::Block(P(b), None),
720720
span: rustc_span::DUMMY_SP,
721721
attrs: AttrVec::new(),
722+
tokens: None,
722723
});
723724

724725
ast::Stmt {
@@ -734,6 +735,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
734735
id: self.resolver.next_node_id(),
735736
span: rustc_span::DUMMY_SP,
736737
attrs: AttrVec::new(),
738+
tokens: None,
737739
});
738740

739741
let loop_stmt = ast::Stmt {

src/librustc_parse/parser/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl RecoverQPath for Expr {
9898
kind: ExprKind::Path(qself, path),
9999
attrs: AttrVec::new(),
100100
id: ast::DUMMY_NODE_ID,
101+
tokens: None,
101102
}
102103
}
103104
}

src/librustc_parse/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2122,7 +2122,7 @@ impl<'a> Parser<'a> {
21222122
}
21232123

21242124
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: AttrVec) -> P<Expr> {
2125-
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
2125+
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID, tokens: None })
21262126
}
21272127

21282128
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {

0 commit comments

Comments
 (0)