forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#102275 - Urgau:stabilize-half_open_range_pa…
…tterns, r=cjgillot Stabilize `half_open_range_patterns` This PR stabilize `feature(half_open_range_patterns)`: ``` Allows using `..=X` as a pattern. ``` And adds a new `feature(half_open_range_patterns_in_slices)` for the slice part, rust-lang#102275 (comment). The FCP was completed in rust-lang#67264.
- Loading branch information
Showing
54 changed files
with
321 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/doc/unstable-book/src/language-features/half-open-range-patterns-in-slices.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# `half_open_range_patterns_in_slices` | ||
|
||
The tracking issue for this feature is: [#67264] | ||
It is part of the `exclusive_range_pattern` feature, | ||
tracked at [#37854]. | ||
|
||
[#67264]: https://github.com/rust-lang/rust/issues/67264 | ||
[#37854]: https://github.com/rust-lang/rust/issues/37854 | ||
----- | ||
|
||
This feature allow using top-level half-open range patterns in slices. | ||
|
||
```rust | ||
#![feature(half_open_range_patterns_in_slices)] | ||
#![feature(exclusive_range_pattern)] | ||
|
||
fn main() { | ||
let xs = [13, 1, 5, 2, 3, 1, 21, 8]; | ||
let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs else { return; }; | ||
} | ||
``` | ||
|
||
Note that this feature is not required if the patterns are wrapped between parenthesis. | ||
|
||
```rust | ||
fn main() { | ||
let xs = [13, 1]; | ||
let [(a @ 3..), c] = xs else { return; }; | ||
} | ||
``` |
27 changes: 0 additions & 27 deletions
27
src/doc/unstable-book/src/language-features/half-open-range-patterns.md
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/test/ui/half-open-range-patterns/exclusive_range_pattern_syntax_collision3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(half_open_range_patterns)] | ||
#![feature(exclusive_range_pattern)] | ||
|
||
fn main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#![feature(exclusive_range_pattern)] | ||
|
||
fn main() { | ||
let xs = [13, 1, 5, 2, 3, 1, 21, 8]; | ||
let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs; | ||
//~^ `X..` patterns in slices are experimental | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns-in-slices.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: `X..` patterns in slices are experimental | ||
--> $DIR/feature-gate-half-open-range-patterns-in-slices.rs:5:10 | ||
| | ||
LL | let [a @ 3.., b @ ..3, c @ 4..6, ..] = xs; | ||
| ^^^^^^^ | ||
| | ||
= note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information | ||
= help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
18 changes: 0 additions & 18 deletions
18
src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.rs
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
src/test/ui/half-open-range-patterns/feature-gate-half-open-range-patterns.stderr
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/test/ui/half-open-range-patterns/half-open-range-pats-bad-types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#![feature(half_open_range_patterns)] | ||
#![feature(exclusive_range_pattern)] | ||
|
||
fn main() { | ||
|
6 changes: 3 additions & 3 deletions
6
src/test/ui/half-open-range-patterns/half-open-range-pats-bad-types.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-fail.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.