diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-14 15:56:05 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-15 20:57:12 +0100 |
| commit | 1c2906ead3825c013ac022249f1e1ee3a3b97c75 (patch) | |
| tree | e11037fc02c6232f587f6dc01eab75f0eb20cfc5 /src/libsyntax | |
| parent | f3e9763543e5828fe9eee7f5e78c88193f5b8ba5 (diff) | |
ast/parser: fuse `static` & `const` grammars in all contexts.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 5 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 61ae14cae02..bbb629012a9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2606,7 +2606,7 @@ pub type ForeignItem = Item<ForeignItemKind>; #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum ForeignItemKind { /// A static item (`static FOO: u8`). - Static(P<Ty>, Mutability), + Static(P<Ty>, Mutability, Option<P<Expr>>), /// A function. Fn(FnSig, Generics, Option<P<Block>>), /// A type. diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index cd7a3becca7..62f640f0bfa 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -1046,7 +1046,10 @@ pub fn noop_flat_map_foreign_item<T: MutVisitor>( visitor.visit_generics(generics); visit_opt(body, |body| visitor.visit_block(body)); } - ForeignItemKind::Static(t, _m) => visitor.visit_ty(t), + ForeignItemKind::Static(ty, _, body) => { + visitor.visit_ty(ty); + visit_opt(body, |body| visitor.visit_expr(body)); + } ForeignItemKind::TyAlias(generics, bounds, ty) => { visitor.visit_generics(generics); visit_bounds(bounds, visitor); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4beb94e9f0c..0dd21cdf12f 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -534,7 +534,10 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI let kind = FnKind::Fn(FnCtxt::Foreign, item.ident, sig, &item.vis, body.as_deref()); visitor.visit_fn(kind, item.span, item.id); } - ForeignItemKind::Static(ref typ, _) => visitor.visit_ty(typ), + ForeignItemKind::Static(ref typ, _, ref body) => { + visitor.visit_ty(typ); + walk_list!(visitor, visit_expr, body); + } ForeignItemKind::TyAlias(ref generics, ref bounds, ref ty) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); |
