diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-01 04:12:28 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-12 17:54:48 +0100 |
| commit | 73557faed23678fc443f3fa52727b5f200f597d2 (patch) | |
| tree | d5b14c48ff17af72abccd66ce88397d1a57490ad /src/libsyntax | |
| parent | c4bbe9cbbe9921646cdedb856e34dc951641ed96 (diff) | |
| download | rust-73557faed23678fc443f3fa52727b5f200f597d2.tar.gz rust-73557faed23678fc443f3fa52727b5f200f597d2.zip | |
Use `Option` in `ImplItemKind::Const`.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/mut_visit.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 964acfa92b9..17a57387da7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1635,8 +1635,8 @@ pub struct ImplItem<K = ImplItemKind> { /// Represents various kinds of content within an `impl`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] -pub enum ImplItemKind { - Const(P<Ty>, P<Expr>), +pub enum ImplItemKind { + Const(P<Ty>, Option<P<Expr>>), Method(FnSig, P<Block>), TyAlias(P<Ty>), Macro(Mac), diff --git a/src/libsyntax/mut_visit.rs b/src/libsyntax/mut_visit.rs index 9d0a29f2951..14701455013 100644 --- a/src/libsyntax/mut_visit.rs +++ b/src/libsyntax/mut_visit.rs @@ -981,7 +981,7 @@ pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut match kind { ImplItemKind::Const(ty, expr) => { visitor.visit_ty(ty); - visitor.visit_expr(expr); + visit_opt(expr, |expr| visitor.visit_expr(expr)); } ImplItemKind::Method(sig, body) => { visit_fn_sig(sig, visitor); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 2e3ea5e2444..c1405e15819 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1599,7 +1599,7 @@ impl<'a> State<'a> { self.print_defaultness(ii.defaultness); match ii.kind { ast::ImplItemKind::Const(ref ty, ref expr) => { - self.print_associated_const(ii.ident, ty, Some(expr), &ii.vis); + self.print_associated_const(ii.ident, ty, expr.as_deref(), &ii.vis); } ast::ImplItemKind::Method(ref sig, ref body) => { self.head(""); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4ee09b4b87a..0b7a7d993aa 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -617,7 +617,7 @@ pub fn walk_impl_item<'a, V: Visitor<'a>>(visitor: &mut V, impl_item: &'a ImplIt match impl_item.kind { ImplItemKind::Const(ref ty, ref expr) => { visitor.visit_ty(ty); - visitor.visit_expr(expr); + walk_list!(visitor, visit_expr, expr); } ImplItemKind::Method(ref sig, ref body) => { visitor.visit_fn(FnKind::Method(impl_item.ident, sig, Some(&impl_item.vis), body), |
