Skip to content

Commit

Permalink
Stabilize inclusive_range library feature.
Browse files Browse the repository at this point in the history
Stabilize std::ops::RangeInclusive and std::ops::RangeInclusiveTo.
  • Loading branch information
kennytm committed Mar 15, 2018
1 parent 5ebf748 commit b5913f2
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 86 deletions.
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Expand Up @@ -98,7 +98,6 @@
#![feature(fundamental)]
#![feature(generic_param_attrs)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(iter_rfold)]
#![feature(lang_items)]
#![feature(needs_allocator)]
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/range.rs
Expand Up @@ -103,7 +103,7 @@ impl<T> RangeArgument<T> for Range<T> {
}
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<T> RangeArgument<T> for RangeInclusive<T> {
fn start(&self) -> Bound<&T> {
Included(&self.start)
Expand All @@ -113,7 +113,7 @@ impl<T> RangeArgument<T> for RangeInclusive<T> {
}
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<T> RangeArgument<T> for RangeToInclusive<T> {
fn start(&self) -> Bound<&T> {
Unbounded
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/string.rs
Expand Up @@ -1876,7 +1876,7 @@ impl ops::Index<ops::RangeFull> for String {
unsafe { str::from_utf8_unchecked(&self.vec) }
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::Index<ops::RangeInclusive<usize>> for String {
type Output = str;

Expand All @@ -1885,7 +1885,7 @@ impl ops::Index<ops::RangeInclusive<usize>> for String {
Index::index(&**self, index)
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::Index<ops::RangeToInclusive<usize>> for String {
type Output = str;

Expand Down Expand Up @@ -1923,14 +1923,14 @@ impl ops::IndexMut<ops::RangeFull> for String {
unsafe { str::from_utf8_unchecked_mut(&mut *self.vec) }
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::IndexMut<ops::RangeInclusive<usize>> for String {
#[inline]
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
IndexMut::index_mut(&mut **self, index)
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::IndexMut<ops::RangeToInclusive<usize>> for String {
#[inline]
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
Expand Down
12 changes: 4 additions & 8 deletions src/libcore/iter/range.rs
Expand Up @@ -186,9 +186,7 @@ macro_rules! range_exact_iter_impl {

macro_rules! range_incl_exact_iter_impl {
($($t:ty)*) => ($(
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ExactSizeIterator for ops::RangeInclusive<$t> { }
)*)
}
Expand All @@ -202,9 +200,7 @@ macro_rules! range_trusted_len_impl {

macro_rules! range_incl_trusted_len_impl {
($($t:ty)*) => ($(
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
unsafe impl TrustedLen for ops::RangeInclusive<$t> { }
)*)
}
Expand Down Expand Up @@ -328,7 +324,7 @@ impl<A: Step> FusedIterator for ops::RangeFrom<A> {}
#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl<A: Step> TrustedLen for ops::RangeFrom<A> {}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<A: Step> Iterator for ops::RangeInclusive<A> {
type Item = A;

Expand Down Expand Up @@ -422,7 +418,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
}
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
#[inline]
fn next_back(&mut self) -> Option<A> {
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops/mod.rs
Expand Up @@ -191,7 +191,7 @@ pub use self::index::{Index, IndexMut};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub use self::range::{RangeInclusive, RangeToInclusive};

#[unstable(feature = "try_trait", issue = "42327")]
Expand Down
24 changes: 9 additions & 15 deletions src/libcore/ops/range.rs
Expand Up @@ -283,7 +283,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// #![feature(inclusive_range,inclusive_range_syntax)]
/// #![feature(inclusive_range_syntax)]
///
/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
Expand All @@ -293,21 +293,17 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
/// ```
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub struct RangeInclusive<Idx> {
/// The lower bound of the range (inclusive).
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub start: Idx,
/// The upper bound of the range (inclusive).
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub end: Idx,
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: fmt::Debug> fmt::Debug for RangeInclusive<Idx> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{:?}..={:?}", self.start, self.end)
Expand Down Expand Up @@ -385,7 +381,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// The `..=end` syntax is a `RangeToInclusive`:
///
/// ```
/// #![feature(inclusive_range,inclusive_range_syntax)]
/// #![feature(inclusive_range_syntax)]
/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
/// ```
///
Expand Down Expand Up @@ -417,16 +413,14 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// [`Iterator`]: ../iter/trait.IntoIterator.html
/// [slicing index]: ../slice/trait.SliceIndex.html
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub struct RangeToInclusive<Idx> {
/// The upper bound of the range (inclusive)
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
pub end: Idx,
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "..={:?}", self.end)
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/slice/mod.rs
Expand Up @@ -1039,7 +1039,7 @@ impl<T> SliceIndex<[T]> for ops::RangeFull {
}


#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
type Output = [T];

Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
}
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
type Output = [T];

Expand Down
24 changes: 6 additions & 18 deletions src/libcore/str/mod.rs
Expand Up @@ -1779,9 +1779,7 @@ mod traits {
}
}

#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::Index<ops::RangeInclusive<usize>> for str {
type Output = str;

Expand All @@ -1791,9 +1789,7 @@ mod traits {
}
}

#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::Index<ops::RangeToInclusive<usize>> for str {
type Output = str;

Expand All @@ -1803,18 +1799,14 @@ mod traits {
}
}

#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::IndexMut<ops::RangeInclusive<usize>> for str {
#[inline]
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
index.index_mut(self)
}
}
#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ops::IndexMut<ops::RangeToInclusive<usize>> for str {
#[inline]
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
Expand Down Expand Up @@ -1997,9 +1989,7 @@ mod traits {
}
}

#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl SliceIndex<str> for ops::RangeInclusive<usize> {
type Output = str;
#[inline]
Expand Down Expand Up @@ -2042,9 +2032,7 @@ mod traits {



#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl SliceIndex<str> for ops::RangeToInclusive<usize> {
type Output = str;
#[inline]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Expand Up @@ -23,7 +23,6 @@
#![feature(fmt_internals)]
#![feature(iterator_step_by)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(inclusive_range_syntax)]
#![feature(iterator_try_fold)]
#![feature(iterator_flatten)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Expand Up @@ -54,7 +54,6 @@
#![feature(fs_read_write)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(windows, feature(libc))]
#![feature(match_default_bindings)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_mir/lib.rs
Expand Up @@ -29,7 +29,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(fs_read_write)]
#![feature(i128_type)]
#![feature(inclusive_range_syntax)]
#![feature(inclusive_range)]
#![feature(macro_vis_matcher)]
#![feature(match_default_bindings)]
#![feature(exhaustive_patterns)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_trans/lib.rs
Expand Up @@ -26,7 +26,6 @@
#![allow(unused_attributes)]
#![feature(i128_type)]
#![feature(i128)]
#![feature(inclusive_range)]
#![feature(inclusive_range_syntax)]
#![feature(libc)]
#![feature(quote)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Expand Up @@ -271,7 +271,6 @@
#![feature(heap_api)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(int_error_internals)]
#![feature(integer_atomics)]
#![feature(into_cow)]
Expand Down
21 changes: 0 additions & 21 deletions src/test/compile-fail/range_inclusive_gate.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/compile-fail/range_traits-1.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(inclusive_range)]

use std::ops::*;

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/range_traits-6.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(inclusive_range)]

use std::ops::*;

#[derive(Copy, Clone)] //~ ERROR Copy
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/range_traits-7.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(rustc_attrs, inclusive_range)]
#![feature(rustc_attrs)]

use std::ops::*;

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

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

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

pub fn main() {
for _ in 1..= {} //~ERROR inclusive range with no end
Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/range_inclusive_dotdotdot.rs
Expand Up @@ -12,7 +12,7 @@

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

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

use std::ops::RangeToInclusive;

Expand Down
2 changes: 1 addition & 1 deletion src/test/parse-fail/range_inclusive_gate.rs
Expand Up @@ -12,7 +12,7 @@

// Make sure that #![feature(inclusive_range_syntax)] is required.

// #![feature(inclusive_range_syntax, inclusive_range)]
// #![feature(inclusive_range_syntax)]

macro_rules! m {
() => { for _ in 1..=10 {} } //~ ERROR inclusive range syntax is experimental
Expand Down
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, inclusive_range, iterator_step_by)]
#![feature(inclusive_range_syntax, iterator_step_by)]

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

Expand Down

0 comments on commit b5913f2

Please sign in to comment.