From 4eb94b44072697be70fc2a74ed9989e88f9cd70c Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 21 Apr 2019 15:29:58 +0300 Subject: AST/HIR: Use `Mutability` instead of bool in foreign statics --- src/libsyntax/ast.rs | 5 ++--- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0668730b3ef..a5472c622e6 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2340,9 +2340,8 @@ pub struct ForeignItem { pub enum ForeignItemKind { /// A foreign function. Fn(P, Generics), - /// A foreign static item (`static ext: u8`), with optional mutability. - /// (The boolean is `true` for mutable items). - Static(P, bool), + /// A foreign static item (`static ext: u8`). + Static(P, Mutability), /// A foreign type. Ty, /// A macro invocation. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 29d2d2ad73d..233ea472e98 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7683,7 +7683,7 @@ impl<'a> Parser<'a> { /// Assumes that the `static` keyword is already parsed. fn parse_item_foreign_static(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec) -> PResult<'a, ForeignItem> { - let mutbl = self.eat_keyword(keywords::Mut); + let mutbl = self.parse_mutability(); let ident = self.parse_ident()?; self.expect(&token::Colon)?; let ty = self.parse_ty()?; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ca05ff71c94..d94e4762e67 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1142,7 +1142,7 @@ impl<'a> State<'a> { } ast::ForeignItemKind::Static(ref t, m) => { self.head(visibility_qualified(&item.vis, "static"))?; - if m { + if m == ast::Mutability::Mutable { self.word_space("mut")?; } self.print_ident(item.ident)?; -- cgit 1.4.1-3-g733a5