Skip to content

Commit

Permalink
Stabilize inclusive_range_syntax language feature.
Browse files Browse the repository at this point in the history
Stabilize the syntax `a..=b` and `..=b`.
  • Loading branch information
kennytm committed Mar 15, 2018
1 parent b5913f2 commit 92d1f8d
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 138 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion src/liballoc/tests/lib.rs
Expand Up @@ -14,7 +14,7 @@
#![feature(alloc_system)]
#![feature(attr_literals)]
#![feature(box_syntax)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(collection_placement)]
#![feature(const_fn)]
#![feature(drain_filter)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Expand Up @@ -79,7 +79,7 @@
#![feature(fn_must_use)]
#![feature(fundamental)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(intrinsics)]
#![feature(iterator_flatten)]
#![feature(iterator_repeat_with)]
Expand Down
19 changes: 6 additions & 13 deletions src/libcore/ops/range.rs
Expand Up @@ -128,7 +128,7 @@ impl<Idx: PartialOrd<Idx>> Range<Idx> {
/// The range is empty if either side is incomparable:
///
/// ```
/// #![feature(range_is_empty,inclusive_range_syntax)]
/// #![feature(range_is_empty)]
///
/// use std::f32::NAN;
/// assert!(!(3.0..5.0).is_empty());
Expand Down Expand Up @@ -283,8 +283,6 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// #![feature(inclusive_range_syntax)]
///
/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
///
Expand Down Expand Up @@ -316,7 +314,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains,inclusive_range_syntax)]
/// #![feature(range_contains)]
///
/// assert!(!(3..=5).contains(2));
/// assert!( (3..=5).contains(3));
Expand All @@ -337,7 +335,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_is_empty,inclusive_range_syntax)]
/// #![feature(range_is_empty)]
///
/// assert!(!(3..=5).is_empty());
/// assert!(!(3..=3).is_empty());
Expand All @@ -347,7 +345,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// The range is empty if either side is incomparable:
///
/// ```
/// #![feature(range_is_empty,inclusive_range_syntax)]
/// #![feature(range_is_empty)]
///
/// use std::f32::NAN;
/// assert!(!(3.0..=5.0).is_empty());
Expand All @@ -358,7 +356,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// This method returns `true` after iteration has finished:
///
/// ```
/// #![feature(range_is_empty,inclusive_range_syntax)]
/// #![feature(range_is_empty)]
///
/// let mut r = 3..=5;
/// for _ in r.by_ref() {}
Expand All @@ -381,16 +379,13 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// The `..=end` syntax is a `RangeToInclusive`:
///
/// ```
/// #![feature(inclusive_range_syntax)]
/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
/// ```
///
/// It does not have an [`IntoIterator`] implementation, so you can't use it in a
/// `for` loop directly. This won't compile:
///
/// ```compile_fail,E0277
/// #![feature(inclusive_range_syntax)]
///
/// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
/// // std::iter::Iterator` is not satisfied
/// for i in ..=5 {
Expand All @@ -402,8 +397,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// array elements up to and including the index indicated by `end`.
///
/// ```
/// #![feature(inclusive_range_syntax)]
///
/// let arr = [0, 1, 2, 3];
/// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
/// assert_eq!(arr[1..=2], [ 1,2 ]);
Expand Down Expand Up @@ -434,7 +427,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
/// # Examples
///
/// ```
/// #![feature(range_contains,inclusive_range_syntax)]
/// #![feature(range_contains)]
///
/// assert!( (..=5).contains(-1_000_000_000));
/// assert!( (..=5).contains(5));
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/lib.rs
Expand Up @@ -23,7 +23,7 @@
#![feature(fmt_internals)]
#![feature(iterator_step_by)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(iterator_try_fold)]
#![feature(iterator_flatten)]
#![feature(conservative_impl_trait)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Expand Up @@ -54,7 +54,7 @@
#![feature(fs_read_write)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![cfg_attr(windows, feature(libc))]
#![feature(match_default_bindings)]
#![feature(macro_lifetime_matcher)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_incremental/lib.rs
Expand Up @@ -18,7 +18,7 @@
#![feature(conservative_impl_trait)]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(specialization)]

extern crate graphviz;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Expand Up @@ -28,7 +28,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(dyn_trait)]
#![feature(fs_read_write)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(macro_vis_matcher)]
#![feature(match_default_bindings)]
#![feature(exhaustive_patterns)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/lib.rs
Expand Up @@ -26,7 +26,7 @@
#![allow(unused_attributes)]
#![feature(i128_type)]
#![feature(i128)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(libc)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
Expand Down
4 changes: 0 additions & 4 deletions src/libsyntax/diagnostic_list.rs
Expand Up @@ -218,8 +218,6 @@ An inclusive range was used with no end.
Erroneous code example:
```compile_fail,E0586
#![feature(inclusive_range_syntax)]
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=]; // error: inclusive range was used with no end
Expand All @@ -239,8 +237,6 @@ fn main() {
Or put an end to your inclusive range:
```
#![feature(inclusive_range_syntax)]
fn main() {
let tmp = vec![0, 1, 2, 3, 4, 4, 3, 3, 2, 1];
let x = &tmp[1..=3]; // ok!
Expand Down
10 changes: 2 additions & 8 deletions src/libsyntax/feature_gate.rs
Expand Up @@ -268,9 +268,6 @@ declare_features! (
// rustc internal
(active, abi_vectorcall, "1.7.0", None, None),

// a..=b and ..=b
(active, inclusive_range_syntax, "1.7.0", Some(28237), None),

// X..Y patterns
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),

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

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1592,11 +1591,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
gate_feature_post!(&self, type_ascription, e.span,
"type ascription is experimental");
}
ast::ExprKind::Range(_, _, ast::RangeLimits::Closed) => {
gate_feature_post!(&self, inclusive_range_syntax,
e.span,
"inclusive range syntax is experimental");
}
ast::ExprKind::InPlace(..) => {
gate_feature_post!(&self, placement_in_syntax, e.span, EXPLAIN_PLACEMENT_IN);
}
Expand Down
1 change: 0 additions & 1 deletion src/test/incremental/hashes/indexing_expressions.rs
Expand Up @@ -23,7 +23,6 @@
#![allow(warnings)]
#![feature(rustc_attrs)]
#![crate_type="rlib"]
#![feature(inclusive_range_syntax)]

// Change simple index ---------------------------------------------------------
#[cfg(cfail1)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/parse-fail/range_inclusive.rs
Expand Up @@ -10,8 +10,6 @@

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

#![feature(inclusive_range_syntax)]

pub fn main() {
for _ in 1..= {} //~ERROR inclusive range with no end
//~^HELP bounded at the end
Expand Down
2 changes: 0 additions & 2 deletions src/test/parse-fail/range_inclusive_dotdotdot.rs
Expand Up @@ -12,8 +12,6 @@

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

#![feature(inclusive_range_syntax)]

use std::ops::RangeToInclusive;

fn return_range_to() -> RangeToInclusive<i32> {
Expand Down
74 changes: 0 additions & 74 deletions src/test/parse-fail/range_inclusive_gate.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/run-pass/range_inclusive.rs
Expand Up @@ -10,7 +10,7 @@

// Test inclusive range syntax.

#![feature(inclusive_range_syntax, iterator_step_by)]
#![feature(iterator_step_by)]

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

Expand Down
3 changes: 1 addition & 2 deletions src/test/run-pass/range_inclusive_gate.rs
Expand Up @@ -9,8 +9,7 @@
// except according to those terms.

// Test that you only need the syntax gate if you don't mention the structs.

#![feature(inclusive_range_syntax)]
// (Obsoleted since both features are stabilized)

fn main() {
let mut count = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/impossible_range.rs
Expand Up @@ -10,8 +10,6 @@

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

#![feature(inclusive_range_syntax)]

pub fn main() {
..;
0..;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/impossible_range.stderr
@@ -1,13 +1,13 @@
error[E0586]: inclusive range with no end
--> $DIR/impossible_range.rs:20:8
--> $DIR/impossible_range.rs:18:8
|
LL | ..=; //~ERROR inclusive range with no end
| ^
|
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)

error[E0586]: inclusive range with no end
--> $DIR/impossible_range.rs:27:9
--> $DIR/impossible_range.rs:25:9
|
LL | 0..=; //~ERROR inclusive range with no end
| ^
Expand Down

0 comments on commit 92d1f8d

Please sign in to comment.