Skip to content

Commit 92d1f8d

Browse files
committed
Stabilize inclusive_range_syntax language feature.
Stabilize the syntax `a..=b` and `..=b`.
1 parent b5913f2 commit 92d1f8d

File tree

19 files changed

+19
-138
lines changed

19 files changed

+19
-138
lines changed

src/doc/unstable-book/src/language-features/inclusive-range-syntax.md

-20
This file was deleted.

src/liballoc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#![feature(alloc_system)]
1515
#![feature(attr_literals)]
1616
#![feature(box_syntax)]
17-
#![feature(inclusive_range_syntax)]
17+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
1818
#![feature(collection_placement)]
1919
#![feature(const_fn)]
2020
#![feature(drain_filter)]

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#![feature(fn_must_use)]
8080
#![feature(fundamental)]
8181
#![feature(i128_type)]
82-
#![feature(inclusive_range_syntax)]
82+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
8383
#![feature(intrinsics)]
8484
#![feature(iterator_flatten)]
8585
#![feature(iterator_repeat_with)]

src/libcore/ops/range.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
128128
/// The range is empty if either side is incomparable:
129129
///
130130
/// ```
131-
/// #![feature(range_is_empty,inclusive_range_syntax)]
131+
/// #![feature(range_is_empty)]
132132
///
133133
/// use std::f32::NAN;
134134
/// assert!(!(3.0..5.0).is_empty());
@@ -283,8 +283,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
283283
/// # Examples
284284
///
285285
/// ```
286-
/// #![feature(inclusive_range_syntax)]
287-
///
288286
/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
289287
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
290288
///
@@ -316,7 +314,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
316314
/// # Examples
317315
///
318316
/// ```
319-
/// #![feature(range_contains,inclusive_range_syntax)]
317+
/// #![feature(range_contains)]
320318
///
321319
/// assert!(!(3..=5).contains(2));
322320
/// assert!( (3..=5).contains(3));
@@ -337,7 +335,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
337335
/// # Examples
338336
///
339337
/// ```
340-
/// #![feature(range_is_empty,inclusive_range_syntax)]
338+
/// #![feature(range_is_empty)]
341339
///
342340
/// assert!(!(3..=5).is_empty());
343341
/// assert!(!(3..=3).is_empty());
@@ -347,7 +345,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
347345
/// The range is empty if either side is incomparable:
348346
///
349347
/// ```
350-
/// #![feature(range_is_empty,inclusive_range_syntax)]
348+
/// #![feature(range_is_empty)]
351349
///
352350
/// use std::f32::NAN;
353351
/// assert!(!(3.0..=5.0).is_empty());
@@ -358,7 +356,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
358356
/// This method returns `true` after iteration has finished:
359357
///
360358
/// ```
361-
/// #![feature(range_is_empty,inclusive_range_syntax)]
359+
/// #![feature(range_is_empty)]
362360
///
363361
/// let mut r = 3..=5;
364362
/// for _ in r.by_ref() {}
@@ -381,16 +379,13 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
381379
/// The `..=end` syntax is a `RangeToInclusive`:
382380
///
383381
/// ```
384-
/// #![feature(inclusive_range_syntax)]
385382
/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
386383
/// ```
387384
///
388385
/// It does not have an [`IntoIterator`] implementation, so you can't use it in a
389386
/// `for` loop directly. This won't compile:
390387
///
391388
/// ```compile_fail,E0277
392-
/// #![feature(inclusive_range_syntax)]
393-
///
394389
/// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
395390
/// // std::iter::Iterator` is not satisfied
396391
/// for i in ..=5 {
@@ -402,8 +397,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
402397
/// array elements up to and including the index indicated by `end`.
403398
///
404399
/// ```
405-
/// #![feature(inclusive_range_syntax)]
406-
///
407400
/// let arr = [0, 1, 2, 3];
408401
/// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
409402
/// assert_eq!(arr[1..=2], [ 1,2 ]);
@@ -434,7 +427,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
434427
/// # Examples
435428
///
436429
/// ```
437-
/// #![feature(range_contains,inclusive_range_syntax)]
430+
/// #![feature(range_contains)]
438431
///
439432
/// assert!( (..=5).contains(-1_000_000_000));
440433
/// assert!( (..=5).contains(5));

src/libcore/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![feature(fmt_internals)]
2424
#![feature(iterator_step_by)]
2525
#![feature(i128_type)]
26-
#![feature(inclusive_range_syntax)]
26+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
2727
#![feature(iterator_try_fold)]
2828
#![feature(iterator_flatten)]
2929
#![feature(conservative_impl_trait)]

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#![feature(fs_read_write)]
5555
#![feature(i128)]
5656
#![feature(i128_type)]
57-
#![feature(inclusive_range_syntax)]
57+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
5858
#![cfg_attr(windows, feature(libc))]
5959
#![feature(match_default_bindings)]
6060
#![feature(macro_lifetime_matcher)]

src/librustc_incremental/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![feature(conservative_impl_trait)]
1919
#![feature(fs_read_write)]
2020
#![feature(i128_type)]
21-
#![feature(inclusive_range_syntax)]
21+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
2222
#![feature(specialization)]
2323

2424
extern crate graphviz;

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2828
#![feature(dyn_trait)]
2929
#![feature(fs_read_write)]
3030
#![feature(i128_type)]
31-
#![feature(inclusive_range_syntax)]
31+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
3232
#![feature(macro_vis_matcher)]
3333
#![feature(match_default_bindings)]
3434
#![feature(exhaustive_patterns)]

src/librustc_trans/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#![allow(unused_attributes)]
2727
#![feature(i128_type)]
2828
#![feature(i128)]
29-
#![feature(inclusive_range_syntax)]
29+
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
3030
#![feature(libc)]
3131
#![feature(quote)]
3232
#![feature(rustc_diagnostic_macros)]

src/libsyntax/diagnostic_list.rs

-4
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ An inclusive range was used with no end.
218218
Erroneous code example:
219219
220220
```compile_fail,E0586
221-
#![feature(inclusive_range_syntax)]
222-
223221
fn main() {
224222
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
225223
let x = &tmp[1..=]; // error: inclusive range was used with no end
@@ -239,8 +237,6 @@ fn main() {
239237
Or put an end to your inclusive range:
240238
241239
```
242-
#![feature(inclusive_range_syntax)]
243-
244240
fn main() {
245241
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
246242
let x = &tmp[1..=3]; // ok!

src/libsyntax/feature_gate.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ declare_features! (
268268
// rustc internal
269269
(active, abi_vectorcall, "1.7.0", None, None),
270270

271-
// a..=b and ..=b
272-
(active, inclusive_range_syntax, "1.7.0", Some(28237), None),
273-
274271
// X..Y patterns
275272
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
276273

@@ -554,6 +551,8 @@ declare_features! (
554551
(accepted, match_beginning_vert, "1.25.0", Some(44101), None),
555552
// Nested groups in `use` (RFC 2128)
556553
(accepted, use_nested_groups, "1.25.0", Some(44494), None),
554+
// a..=b and ..=b
555+
(accepted, inclusive_range_syntax, "1.26.0", Some(28237), None),
557556
);
558557

559558
// If you change this, please modify src/doc/unstable-book as well. You must
@@ -1592,11 +1591,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15921591
gate_feature_post!(&self, type_ascription, e.span,
15931592
"type ascription is experimental");
15941593
}
1595-
ast::ExprKind::Range(_, _, ast::RangeLimits::Closed) => {
1596-
gate_feature_post!(&self, inclusive_range_syntax,
1597-
e.span,
1598-
"inclusive range syntax is experimental");
1599-
}
16001594
ast::ExprKind::InPlace(..) => {
16011595
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
16021596
}

src/test/incremental/hashes/indexing_expressions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![allow(warnings)]
2424
#![feature(rustc_attrs)]
2525
#![crate_type="rlib"]
26-
#![feature(inclusive_range_syntax)]
2726

2827
// Change simple index ---------------------------------------------------------
2928
#[cfg(cfail1)]

src/test/parse-fail/range_inclusive.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Make sure that inclusive ranges with no end point don't parse.
1212

13-
#![feature(inclusive_range_syntax)]
14-
1513
pub fn main() {
1614
for _ in 1..= {} //~ERROR inclusive range with no end
1715
//~^HELP bounded at the end

src/test/parse-fail/range_inclusive_dotdotdot.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
// Make sure that inclusive ranges with `...` syntax don't parse.
1414

15-
#![feature(inclusive_range_syntax)]
16-
1715
use std::ops::RangeToInclusive;
1816

1917
fn return_range_to() -> RangeToInclusive<i32> {

src/test/parse-fail/range_inclusive_gate.rs

-74
This file was deleted.

src/test/run-pass/range_inclusive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Test inclusive range syntax.
1212

13-
#![feature(inclusive_range_syntax, iterator_step_by)]
13+
#![feature(iterator_step_by)]
1414

1515
use std::ops::{RangeInclusive, RangeToInclusive};
1616

src/test/run-pass/range_inclusive_gate.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
// except according to those terms.
1010

1111
// Test that you only need the syntax gate if you don't mention the structs.
12-
13-
#![feature(inclusive_range_syntax)]
12+
// (Obsoleted since both features are stabilized)
1413

1514
fn main() {
1615
let mut count = 0;

src/test/ui/impossible_range.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Make sure that invalid ranges generate an error during HIR lowering, not an ICE
1212

13-
#![feature(inclusive_range_syntax)]
14-
1513
pub fn main() {
1614
..;
1715
0..;

src/test/ui/impossible_range.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0586]: inclusive range with no end
2-
--> $DIR/impossible_range.rs:20:8
2+
--> $DIR/impossible_range.rs:18:8
33
|
44
LL | ..=; //~ERROR inclusive range with no end
55
| ^
66
|
77
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
88

99
error[E0586]: inclusive range with no end
10-
--> $DIR/impossible_range.rs:27:9
10+
--> $DIR/impossible_range.rs:25:9
1111
|
1212
LL | 0..=; //~ERROR inclusive range with no end
1313
| ^

0 commit comments

Comments
 (0)