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(slice_patterns)] in 1.42.0 #67712

Merged
merged 8 commits into from
Jan 18, 2020
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
32 changes: 0 additions & 32 deletions src/doc/unstable-book/src/language-features/slice-patterns.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
#![feature(associated_type_bounds)]
#![feature(const_type_id)]
#![feature(const_caller_location)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]

#[prelude_import]
#[allow(unused)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![feature(range_is_empty)]
#![feature(raw)]
#![feature(saturating_neg)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(sort_internals)]
#![feature(slice_partition_at_index)]
#![feature(specialization)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/benches/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(test)]

extern crate test;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#![feature(optin_builtin_traits)]
#![feature(option_expect_none)]
#![feature(range_is_empty)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(thread_local)]
Expand Down
21 changes: 0 additions & 21 deletions src/librustc_ast_passes/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,29 +470,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_expr(self, e)
}

fn visit_arm(&mut self, arm: &'a ast::Arm) {
visit::walk_arm(self, arm)
}

fn visit_pat(&mut self, pattern: &'a ast::Pat) {
match &pattern.kind {
PatKind::Slice(pats) => {
for pat in &*pats {
let span = pat.span;
let inner_pat = match &pat.kind {
PatKind::Ident(.., Some(pat)) => pat,
_ => pat,
};
if inner_pat.is_rest() {
gate_feature_post!(
&self,
slice_patterns,
span,
"subslice patterns are unstable"
);
}
}
}
PatKind::Box(..) => {
gate_feature_post!(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_passes/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! parsed by `rustc_parse` and then lowered, after the passes in this crate,
//! by `rustc_ast_lowering`.

#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]

pub mod ast_validation;
pub mod feature_gate;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(libc)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(stmt_expr_attributes)]
#![feature(try_blocks)]
#![feature(in_band_lifetimes)]
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_error_codes/error_codes/E0527.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Ensure that the pattern is consistent with the size of the matched
array. Additional elements can be matched with `..`:

```
#![feature(slice_patterns)]

let r = &[1, 2, 3, 4];
match r {
&[a, b, ..] => { // ok!
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_error_codes/error_codes/E0528.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ matched array.
Example of erroneous code:

```compile_fail,E0528
#![feature(slice_patterns)]

let r = &[1, 2];
match r {
&[a, b, c, rest @ ..] => { // error: pattern requires at least 3
Expand All @@ -19,8 +17,6 @@ Ensure that the matched array has at least as many elements as the pattern
requires. You can match an arbitrary number of remaining elements with `..`:

```
#![feature(slice_patterns)]

let r = &[1, 2, 3, 4, 5];
match r {
&[a, b, c, rest @ ..] => { // ok!
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_error_codes/error_codes/E0730.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Ensure that the pattern is consistent with the size of the matched
array. Additional elements can be matched with `..`:

```
#![feature(slice_patterns)]

let r = &[1, 2, 3, 4];
match r {
&[a, b, ..] => { // ok!
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_feature/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ declare_features! (
/// Allows relaxing the coherence rules such that
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
/// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`.
(accepted, slice_patterns, "1.42.0", Some(62254), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_feature/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ declare_features! (
/// Allows using non lexical lifetimes (RFC 2094).
(active, nll, "1.0.0", Some(43234), None),

/// Allows using slice patterns.
(active, slice_patterns, "1.0.0", Some(62254), None),

/// Allows the definition of `const` functions with some advanced features.
(active, const_fn, "1.2.0", Some(57563), None),

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(specialization)]
#![feature(stmt_expr_attributes)]
#![recursion_limit = "256"]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(nll)]
#![feature(in_band_lifetimes)]
#![feature(inner_deref)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(box_syntax)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(crate_visibility_modifier)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(bool_to_option)]
#![recursion_limit = "256"]

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#![feature(bool_to_option)]
#![feature(crate_visibility_modifier)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]

use syntax::ast;
use syntax::print::pprust;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_target/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#![feature(box_syntax)]
#![feature(bool_to_option)]
#![feature(nll)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]

#[macro_use]
extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ty/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#![feature(bool_to_option)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![recursion_limit = "256"]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ This API is completely unstable and subject to change.
#![feature(exhaustive_patterns)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(try_blocks)]
#![feature(never_type)]
#![recursion_limit = "256"]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
#![feature(shrink_to)]
#![feature(slice_concat_ext)]
#![feature(slice_internals)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(specialization)]
#![feature(staged_api)]
#![feature(std_internals)]
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![feature(label_break_value)]
#![feature(nll)]
#![feature(try_trait)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(slice_patterns))]
#![feature(unicode_internals)]
#![recursion_limit = "256"]

Expand Down
1 change: 0 additions & 1 deletion src/test/mir-opt/uniform_array_move_out.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![feature(box_syntax)]
#![feature(slice_patterns)]

fn move_out_from_end() {
let a = [box 1, box 2];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(slice_patterns)]

fn main() {
match "foo".to_string() {
['f', 'o', ..] => {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
error[E0425]: cannot find value `does_not_exist` in this scope
--> $DIR/match-vec-mismatch.rs:28:11
--> $DIR/slice-pat-type-mismatches.rs:26:11
|
LL | match does_not_exist {
| ^^^^^^^^^^^^^^ not found in this scope

error[E0529]: expected an array or slice, found `std::string::String`
--> $DIR/match-vec-mismatch.rs:5:9
--> $DIR/slice-pat-type-mismatches.rs:3:9
|
LL | ['f', 'o', ..] => {}
| ^^^^^^^^^^^^^^ pattern cannot match with input type `std::string::String`

error[E0527]: pattern requires 1 element but array has 3
--> $DIR/match-vec-mismatch.rs:20:9
--> $DIR/slice-pat-type-mismatches.rs:18:9
|
LL | [0] => {},
| ^^^ expected 3 elements

error[E0528]: pattern requires at least 4 elements but array has 3
--> $DIR/match-vec-mismatch.rs:25:9
--> $DIR/slice-pat-type-mismatches.rs:23:9
|
LL | [0, 1, 2, 3, x @ ..] => {}
| ^^^^^^^^^^^^^^^^^^^^ pattern cannot match array of 3 elements

error[E0282]: type annotations needed
--> $DIR/match-vec-mismatch.rs:36:9
--> $DIR/slice-pat-type-mismatches.rs:34:9
|
LL | [] => {}
| ^^ cannot infer type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ fn main() {
match a {
[1, tail @ .., tail @ ..] => {},
//~^ ERROR identifier `tail` is bound more than once in the same pattern
//~| ERROR subslice patterns are unstable
//~| ERROR subslice patterns are unstable
//~| ERROR `..` can only be used once per slice pattern
_ => ()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error[E0416]: identifier `tail` is bound more than once in the same pattern
--> $DIR/subslice-only-once-semantic-restriction.rs:4:24
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^ used in a pattern more than once

error: `..` can only be used once per slice pattern
--> $DIR/subslice-only-once-semantic-restriction.rs:4:31
|
LL | [1, tail @ .., tail @ ..] => {},
| -- ^^ can only be used once per slice pattern
| |
| previously used here

error[E0308]: mismatched types
--> $DIR/subslice-only-once-semantic-restriction.rs:11:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected `()`, found integer

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0308, E0416.
For more information about an error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// run-pass

#![feature(slice_patterns, const_fn, const_if_match)]
#![feature(const_fn, const_if_match)]
#[derive(PartialEq, Debug, Clone)]
struct N(u8);

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/array-slice-vec/subslice-patterns-const-eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

// run-pass

#![feature(slice_patterns)]

#[derive(PartialEq, Debug, Clone)]
struct N(u8);

Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/array-slice-vec/subslice-patterns-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

// run-pass

#![feature(slice_patterns)]

#![allow(unreachable_patterns)]

use std::convert::identity;
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/array-slice-vec/vec-matching-fixed.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(slice_patterns)]

fn a() {
let x = [1, 2, 3];
match x {
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/array-slice-vec/vec-matching-fold.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(slice_patterns)]

use std::fmt::Debug;

fn foldl<T, U, F>(values: &[T],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// run-pass
#![allow(unused_variables)]

#![feature(slice_patterns)]
#![allow(unused_variables)]

pub fn main() {
let x = &[1, 2, 3, 4, 5];
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/array-slice-vec/vec-matching.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// run-pass

#![feature(slice_patterns)]

fn a() {
let x = [1];
match x {
Expand Down
Loading