diff options
| author | bors <bors@rust-lang.org> | 2015-11-01 13:36:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-11-01 13:36:49 +0000 |
| commit | 6d43fef3aaf64b2e7df14ca676a3a39b723ed7f3 (patch) | |
| tree | c49e644a1cff508f4bf9ea482cb2a358e34fef23 /src/libsyntax | |
| parent | a5fbb3a25faeb08f50f571a6aa227f14a9d086c2 (diff) | |
| parent | 306b0efc44f788df2c95553920eddb0bee0bf665 (diff) | |
| download | rust-6d43fef3aaf64b2e7df14ca676a3a39b723ed7f3.tar.gz rust-6d43fef3aaf64b2e7df14ca676a3a39b723ed7f3.zip | |
Auto merge of #29486 - petrochenkov:multiwild, r=Manishearth
Motivation: - It is not actually a pattern - It is not actually needed, except for... Drawback: - Slice patterns like `[a, _.., b]` are pretty-printed as `[a, .., b]`. Great loss :( plugin-[breaking-change], as always
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 14 | ||||
| -rw-r--r-- | src/libsyntax/ext/base.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 2 |
7 files changed, 13 insertions, 28 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 7b3c33d53a3..4e215b32a09 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -31,7 +31,6 @@ pub use self::MetaItem_::*; pub use self::Mutability::*; pub use self::Pat_::*; pub use self::PathListItem_::*; -pub use self::PatWildKind::*; pub use self::PrimTy::*; pub use self::Sign::*; pub use self::Stmt_::*; @@ -569,19 +568,10 @@ pub enum BindingMode { BindByValue(Mutability), } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] -pub enum PatWildKind { - /// Represents the wildcard pattern `_` - PatWildSingle, - - /// Represents the wildcard pattern `..` - PatWildMulti, -} - #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum Pat_ { - /// Represents a wildcard pattern (either `_` or `..`) - PatWild(PatWildKind), + /// Represents a wildcard pattern (`_`) + PatWild, /// A PatIdent may either be a new bound variable, /// or a nullary enum (in which case the third field diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a248f839d73..88862099d81 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -356,7 +356,7 @@ impl DummyResult { pub fn raw_pat(sp: Span) -> ast::Pat { ast::Pat { id: ast::DUMMY_NODE_ID, - node: ast::PatWild(ast::PatWildSingle), + node: ast::PatWild, span: sp, } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 16a5eb05c4b..4c10a749683 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -801,7 +801,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { P(ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, span: span }) } fn pat_wild(&self, span: Span) -> P<ast::Pat> { - self.pat(span, ast::PatWild(ast::PatWildSingle)) + self.pat(span, ast::PatWild) } fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> { self.pat(span, ast::PatLit(expr)) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index be910285db3..d637343de04 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -1125,7 +1125,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> { p.map(|Pat {id, node, span}| Pat { id: folder.new_id(id), node: match node { - PatWild(k) => PatWild(k), + PatWild => PatWild, PatIdent(binding_mode, pth1, sub) => { PatIdent(binding_mode, Spanned{span: folder.new_span(pth1.span), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index d1fc8ac2002..ba86f85c381 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -41,8 +41,7 @@ use ast::{MutImmutable, MutMutable, Mac_}; use ast::{MutTy, BiMul, Mutability}; use ast::{MethodImplItem, NamedField, UnNeg, NoReturn, UnNot}; use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange}; -use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild, PatWildMulti}; -use ast::PatWildSingle; +use ast::{PatRegion, PatStruct, PatTup, PatVec, PatWild}; use ast::{PolyTraitRef, QSelf}; use ast::{Return, BiShl, BiShr, Stmt, StmtDecl}; use ast::{StmtExpr, StmtSemi, StmtMac, VariantData, StructField}; @@ -3078,7 +3077,7 @@ impl<'a> Parser<'a> { self.check(&token::CloseDelim(token::Bracket)) { slice = Some(P(ast::Pat { id: ast::DUMMY_NODE_ID, - node: PatWild(PatWildMulti), + node: PatWild, span: self.span, })); before_slice = false; @@ -3215,7 +3214,7 @@ impl<'a> Parser<'a> { token::Underscore => { // Parse _ try!(self.bump()); - pat = PatWild(PatWildSingle); + pat = PatWild; } token::BinOp(token::And) | token::AndAnd => { // Parse &pat / &mut pat diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0bdbf132cb8..2ab94b41c74 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2406,8 +2406,7 @@ impl<'a> State<'a> { /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ match pat.node { - ast::PatWild(ast::PatWildSingle) => try!(word(&mut self.s, "_")), - ast::PatWild(ast::PatWildMulti) => try!(word(&mut self.s, "..")), + ast::PatWild => try!(word(&mut self.s, "_")), ast::PatIdent(binding_mode, ref path1, ref sub) => { match binding_mode { ast::BindByRef(mutbl) => { @@ -2503,13 +2502,10 @@ impl<'a> State<'a> { |s, p| s.print_pat(&**p))); if let Some(ref p) = *slice { if !before.is_empty() { try!(self.word_space(",")); } - try!(self.print_pat(&**p)); - match **p { - ast::Pat { node: ast::PatWild(ast::PatWildMulti), .. } => { - // this case is handled by print_pat - } - _ => try!(word(&mut self.s, "..")), + if p.node != ast::PatWild { + try!(self.print_pat(&**p)); } + try!(word(&mut self.s, "..")); if !after.is_empty() { try!(self.word_space(",")); } } try!(self.commasep(Inconsistent, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 1614d7d4517..a35a1c1cffd 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -451,7 +451,7 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) { visitor.visit_expr(lower_bound); visitor.visit_expr(upper_bound) } - PatWild(_) => (), + PatWild => (), PatVec(ref prepatterns, ref slice_pattern, ref postpatterns) => { walk_list!(visitor, visit_pat, prepatterns); walk_list!(visitor, visit_pat, slice_pattern); |
