Skip to content

Commit

Permalink
Rollup merge of rust-lang#124459 - RossSmyth:stable_range, r=davidtwco
Browse files Browse the repository at this point in the history
Stabilize exclusive_range_pattern

Stabilization report: rust-lang#37854 (comment)
FCP: rust-lang#37854 (comment)

Stabilization was blocked by a lint that was merged here: rust-lang#118879

Documentation PR is here: rust-lang/reference#1484

`@rustbot` label +F-exclusive_range_pattern +T-lang
  • Loading branch information
fmease authored May 5, 2024
2 parents add679b + 57f00ce commit 592068d
Show file tree
Hide file tree
Showing 84 changed files with 366 additions and 691 deletions.
15 changes: 1 addition & 14 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_ast as ast;
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::{attr, AssocConstraint, AssocConstraintKind, NodeId};
use rustc_ast::{token, PatKind, RangeEnd};
use rustc_ast::{token, PatKind};
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
use rustc_session::Session;
Expand Down Expand Up @@ -418,15 +418,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
PatKind::Box(..) => {
gate!(&self, box_patterns, pattern.span, "box pattern syntax is experimental");
}
PatKind::Range(_, Some(_), Spanned { node: RangeEnd::Excluded, .. }) => {
gate!(
&self,
exclusive_range_pattern,
pattern.span,
"exclusive range pattern syntax is experimental",
"use an inclusive range pattern, like N..=M"
);
}
_ => {}
}
visit::walk_pat(self, pattern)
Expand Down Expand Up @@ -619,10 +610,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
// be too.
gate_all_legacy_dont_use!(return_type_notation, "return type notation is experimental");
gate_all_legacy_dont_use!(decl_macro, "`macro` is experimental");
gate_all_legacy_dont_use!(
exclusive_range_pattern,
"exclusive range pattern syntax is experimental"
);
gate_all_legacy_dont_use!(try_blocks, "`try` blocks are unstable");
gate_all_legacy_dont_use!(auto_traits, "`auto` traits are unstable");

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_error_codes/src/error_codes/E0579.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ A lower range wasn't less than the upper range.
Erroneous code example:

```compile_fail,E0579
#![feature(exclusive_range_pattern)]
fn main() {
match 5u32 {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ declare_features! (
(accepted, drop_types_in_const, "1.22.0", Some(33156)),
/// Allows using `dyn Trait` as a syntax for trait objects.
(accepted, dyn_trait, "1.27.0", Some(44662)),
/// Allows `X..Y` patterns.
(accepted, exclusive_range_pattern, "CURRENT_RUSTC_VERSION", Some(37854)),
/// Allows integer match exhaustiveness checking (RFC 2591).
(accepted, exhaustive_integer_patterns, "1.33.0", Some(50907)),
/// Allows explicit generic arguments specification with `impl Trait` present.
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,6 @@ declare_features! (
(incomplete, dyn_star, "1.65.0", Some(102425)),
/// Uses generic effect parameters for ~const bounds
(unstable, effects, "1.72.0", Some(102090)),
/// Allows `X..Y` patterns.
(unstable, exclusive_range_pattern, "1.11.0", Some(37854)),
/// Allows exhaustive pattern matching on types that contain uninhabited types.
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
/// Allows explicit tail calls via `become` expression.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// # #![feature(exclusive_range_pattern)]
/// let x = 123u32;
/// match x {
/// 0..100 => { println!("small"); }
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_pattern_analysis/src/usefulness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
//! This is enough to compute usefulness: a pattern in a `match` expression is redundant iff it is
//! not useful w.r.t. the patterns above it:
//! ```compile_fail,E0004
//! # #![feature(exclusive_range_pattern)]
//! # fn foo() {
//! match Some(0u32) {
//! Some(0..100) => {},
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
//
// Language features:
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(exclusive_range_pattern))]
#![cfg_attr(not(test), feature(coroutine_trait))]
#![cfg_attr(test, feature(panic_update_hook))]
#![cfg_attr(test, feature(test))]
Expand All @@ -179,7 +180,6 @@
#![feature(const_try)]
#![feature(decl_macro)]
#![feature(dropck_eyepatch)]
#![feature(exclusive_range_pattern)]
#![feature(fundamental)]
#![feature(hashmap_internals)]
#![feature(lang_items)]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `half_open_range_patterns_in_slices`

The tracking issue for this feature is: [#67264]
It is part of the `exclusive_range_pattern` feature,
It is a future part of the `exclusive_range_pattern` feature,
tracked at [#37854].

[#67264]: https://github.com/rust-lang/rust/issues/67264
Expand All @@ -12,7 +12,6 @@ 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];
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/almost_complete_range.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@edition:2018
//@aux-build:proc_macros.rs

#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]
#![warn(clippy::almost_complete_range)]
#![allow(ellipsis_inclusive_range_patterns)]
Expand Down
1 change: 0 additions & 1 deletion src/tools/clippy/tests/ui/almost_complete_range.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@edition:2018
//@aux-build:proc_macros.rs

#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]
#![warn(clippy::almost_complete_range)]
#![allow(ellipsis_inclusive_range_patterns)]
Expand Down
54 changes: 27 additions & 27 deletions src/tools/clippy/tests/ui/almost_complete_range.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:18:17
--> tests/ui/almost_complete_range.rs:17:17
|
LL | let _ = ('a') ..'z';
| ^^^^^^--^^^
Expand All @@ -10,119 +10,119 @@ LL | let _ = ('a') ..'z';
= help: to override `-D warnings` add `#[allow(clippy::almost_complete_range)]`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:19:17
--> tests/ui/almost_complete_range.rs:18:17
|
LL | let _ = 'A' .. ('Z');
| ^^^^--^^^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:20:17
--> tests/ui/almost_complete_range.rs:19:17
|
LL | let _ = ((('0'))) .. ('9');
| ^^^^^^^^^^--^^^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:27:13
--> tests/ui/almost_complete_range.rs:26:13
|
LL | let _ = (b'a')..(b'z');
| ^^^^^^--^^^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:28:13
--> tests/ui/almost_complete_range.rs:27:13
|
LL | let _ = b'A'..b'Z';
| ^^^^--^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:29:13
--> tests/ui/almost_complete_range.rs:28:13
|
LL | let _ = b'0'..b'9';
| ^^^^--^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:35:13
--> tests/ui/almost_complete_range.rs:34:13
|
LL | let _ = inline!('a')..'z';
| ^^^^^^^^^^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:36:13
--> tests/ui/almost_complete_range.rs:35:13
|
LL | let _ = inline!('A')..'Z';
| ^^^^^^^^^^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:37:13
--> tests/ui/almost_complete_range.rs:36:13
|
LL | let _ = inline!('0')..'9';
| ^^^^^^^^^^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:40:9
--> tests/ui/almost_complete_range.rs:39:9
|
LL | b'a'..b'z' if true => 1,
| ^^^^--^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:41:9
--> tests/ui/almost_complete_range.rs:40:9
|
LL | b'A'..b'Z' if true => 2,
| ^^^^--^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:42:9
--> tests/ui/almost_complete_range.rs:41:9
|
LL | b'0'..b'9' if true => 3,
| ^^^^--^^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:50:9
--> tests/ui/almost_complete_range.rs:49:9
|
LL | 'a'..'z' if true => 1,
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:51:9
--> tests/ui/almost_complete_range.rs:50:9
|
LL | 'A'..'Z' if true => 2,
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:52:9
--> tests/ui/almost_complete_range.rs:51:9
|
LL | '0'..'9' if true => 3,
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:65:17
--> tests/ui/almost_complete_range.rs:64:17
|
LL | let _ = 'a'..'z';
| ^^^--^^^
Expand All @@ -132,7 +132,7 @@ LL | let _ = 'a'..'z';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:66:17
--> tests/ui/almost_complete_range.rs:65:17
|
LL | let _ = 'A'..'Z';
| ^^^--^^^
Expand All @@ -142,7 +142,7 @@ LL | let _ = 'A'..'Z';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:67:17
--> tests/ui/almost_complete_range.rs:66:17
|
LL | let _ = '0'..'9';
| ^^^--^^^
Expand All @@ -152,71 +152,71 @@ LL | let _ = '0'..'9';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:74:9
--> tests/ui/almost_complete_range.rs:73:9
|
LL | 'a'..'z' => 1,
| ^^^--^^^
| |
| help: use an inclusive range: `...`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:75:9
--> tests/ui/almost_complete_range.rs:74:9
|
LL | 'A'..'Z' => 2,
| ^^^--^^^
| |
| help: use an inclusive range: `...`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:76:9
--> tests/ui/almost_complete_range.rs:75:9
|
LL | '0'..'9' => 3,
| ^^^--^^^
| |
| help: use an inclusive range: `...`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:83:13
--> tests/ui/almost_complete_range.rs:82:13
|
LL | let _ = 'a'..'z';
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:84:13
--> tests/ui/almost_complete_range.rs:83:13
|
LL | let _ = 'A'..'Z';
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:85:13
--> tests/ui/almost_complete_range.rs:84:13
|
LL | let _ = '0'..'9';
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:87:9
--> tests/ui/almost_complete_range.rs:86:9
|
LL | 'a'..'z' => 1,
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:88:9
--> tests/ui/almost_complete_range.rs:87:9
|
LL | 'A'..'Z' => 1,
| ^^^--^^^
| |
| help: use an inclusive range: `..=`

error: almost complete ascii range
--> tests/ui/almost_complete_range.rs:89:9
--> tests/ui/almost_complete_range.rs:88:9
|
LL | '0'..'9' => 3,
| ^^^--^^^
Expand Down
Loading

0 comments on commit 592068d

Please sign in to comment.