Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize feature(match_beginning_vert) #47947

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

1 change: 0 additions & 1 deletion src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ pub struct Arm {
pub pats: Vec<P<Pat>>,
pub guard: Option<P<Expr>>,
pub body: P<Expr>,
pub beginning_vert: Option<Span>, // For RFC 1925 feature gate
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
pats,
guard: None,
body: expr,
beginning_vert: None,
}
}

Expand Down
10 changes: 2 additions & 8 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,6 @@ declare_features! (
// allow `#[must_use]` on functions and comparison operators (RFC 1940)
(active, fn_must_use, "1.21.0", Some(43302)),

// allow '|' at beginning of match arms (RFC 1925)
(active, match_beginning_vert, "1.21.0", Some(44101)),

// Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008)
(active, non_exhaustive, "1.22.0", Some(44109)),

Expand Down Expand Up @@ -545,6 +542,8 @@ declare_features! (
(accepted, abi_sysv64, "1.24.0", Some(36167)),
// Allows `repr(align(16))` struct attribute (RFC 1358)
(accepted, repr_align, "1.24.0", Some(33626)),
// allow '|' at beginning of match arms (RFC 1925)
(accepted, match_beginning_vert, "1.25.0", Some(44101)),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1678,11 +1677,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
}

fn visit_arm(&mut self, arm: &'a ast::Arm) {
if let Some(span) = arm.beginning_vert {
gate_feature_post!(&self, match_beginning_vert,
span,
"Use of a '|' at the beginning of a match arm is experimental")
}
visit::walk_arm(self, arm)
}

Expand Down
3 changes: 1 addition & 2 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,13 @@ pub fn fold_thin_attrs<T: Folder>(attrs: ThinVec<Attribute>, fld: &mut T) -> Thi
fold_attrs(attrs.into(), fld).into()
}

pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body, beginning_vert}: Arm,
pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body}: Arm,
fld: &mut T) -> Arm {
Arm {
attrs: fold_attrs(attrs, fld),
pats: pats.move_map(|x| fld.fold_pat(x)),
guard: guard.map(|x| fld.fold_expr(x)),
body: fld.fold_expr(body),
beginning_vert,
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3398,11 +3398,7 @@ impl<'a> Parser<'a> {

let attrs = self.parse_outer_attributes()?;
// Allow a '|' before the pats (RFC 1925)
let beginning_vert = if self.eat(&token::BinOp(token::Or)) {
Some(self.prev_span)
} else {
None
};
self.eat(&token::BinOp(token::Or));
let pats = self.parse_pats()?;
let guard = if self.eat_keyword(keywords::If) {
Some(self.parse_expr()?)
Expand All @@ -3426,7 +3422,6 @@ impl<'a> Parser<'a> {
pats,
guard,
body: expr,
beginning_vert,
})
}

Expand Down
28 changes: 28 additions & 0 deletions src/test/run-pass/match-beginning-vert.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

enum Foo {
A,
B,
C,
D,
E,
}
use Foo::*;

fn main() {
for foo in &[A, B, C, D, E] {
match *foo {
| A => println!("A"),
| B | C if 1 < 2 => println!("BC!"),
| _ => {},
}
}
}
36 changes: 0 additions & 36 deletions src/test/ui/feature-gate-match_beginning_vert.rs

This file was deleted.

26 changes: 0 additions & 26 deletions src/test/ui/feature-gate-match_beginning_vert.stderr

This file was deleted.