Skip to content

Stabilize the inclusive_range lib feature #43086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#![feature(fused)]
#![feature(generic_param_attrs)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(lang_items)]
#![feature(manually_drop)]
#![feature(needs_allocator)]
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/range.rs
Original file line number Diff line number Diff line change
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.21.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.21.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
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,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.21.0")]
impl ops::Index<ops::RangeInclusive<usize>> for String {
type Output = str;

Expand All @@ -1780,7 +1780,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.21.0")]
impl ops::Index<ops::RangeToInclusive<usize>> for String {
type Output = str;

Expand Down Expand Up @@ -1818,14 +1818,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.21.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.21.0")]
impl ops::IndexMut<ops::RangeToInclusive<usize>> for String {
#[inline]
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ impl<T> ops::Index<ops::RangeFull> for Vec<T> {
self
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.0")]
impl<T> ops::Index<ops::RangeInclusive<usize>> for Vec<T> {
type Output = [T];

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

Expand Down Expand Up @@ -1649,14 +1649,14 @@ impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
self
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.0")]
impl<T> ops::IndexMut<ops::RangeInclusive<usize>> for Vec<T> {
#[inline]
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut [T] {
IndexMut::index_mut(&mut **self, index)
}
}
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.0")]
impl<T> ops::IndexMut<ops::RangeToInclusive<usize>> for Vec<T> {
#[inline]
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut [T] {
Expand Down
12 changes: 4 additions & 8 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,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.21.0")]
impl ExactSizeIterator for ops::RangeInclusive<$t> { }
)*)
}
Expand All @@ -269,9 +267,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.21.0")]
unsafe impl TrustedLen for ops::RangeInclusive<$t> { }
)*)
}
Expand Down Expand Up @@ -359,7 +355,7 @@ impl<A: Step> Iterator for ops::RangeFrom<A> where
impl<A> FusedIterator for ops::RangeFrom<A>
where A: Step, for<'a> &'a A: Add<&'a A, Output = A> {}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.0")]
impl<A: Step> Iterator for ops::RangeInclusive<A> where
for<'a> &'a A: Add<&'a A, Output = A>
{
Expand Down Expand Up @@ -396,7 +392,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> where
}
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.0")]
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
for<'a> &'a A: Add<&'a A, Output = A>,
for<'a> &'a A: Sub<&'a A, Output = A>
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,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.21.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
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// # Examples
///
/// ```
/// #![feature(inclusive_range,inclusive_range_syntax)]
/// #![feature(inclusive_range_syntax)]
/// fn main() {
/// assert_eq!((3...5), std::ops::RangeInclusive{ start: 3, end: 5 });
/// assert_eq!(3+4+5, (3...5).sum());
Expand All @@ -251,21 +251,17 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
/// }
/// ```
#[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.21.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.21.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.21.0")]
pub end: Idx,
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.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 @@ -306,7 +302,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// The `...{integer}` syntax is a `RangeToInclusive`:
///
/// ```
/// #![feature(inclusive_range,inclusive_range_syntax)]
/// #![feature(inclusive_range_syntax)]
/// assert_eq!((...5), std::ops::RangeToInclusive{ end: 5 });
/// ```
///
Expand All @@ -330,16 +326,14 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
/// assert_eq!(arr[1...2], [ 1,2 ]);
/// ```
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.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.21.0")]
pub end: Idx,
}

#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.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
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,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.21.0")]
impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
type Output = [T];

Expand Down Expand Up @@ -1030,7 +1030,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.21.0")]
impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {
type Output = [T];

Expand Down
16 changes: 4 additions & 12 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1695,9 +1695,7 @@ mod traits {
}
}

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

Expand All @@ -1707,9 +1705,7 @@ mod traits {
}
}

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

Expand All @@ -1719,18 +1715,14 @@ mod traits {
}
}

#[unstable(feature = "inclusive_range",
reason = "recently added, follows RFC",
issue = "28237")]
#[stable(feature = "inclusive_range", since = "1.21.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.21.0")]
impl ops::IndexMut<ops::RangeToInclusive<usize>> for str {
#[inline]
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#![feature(fmt_internals)]
#![feature(iterator_step_by)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(iter_rfind)]
#![feature(libc)]
#![feature(nonzero)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@
#![feature(heap_api)]
#![feature(i128)]
#![feature(i128_type)]
#![feature(inclusive_range)]
#![feature(int_error_internals)]
#![feature(integer_atomics)]
#![feature(into_cow)]
Expand Down
23 changes: 0 additions & 23 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
Original file line number Diff line number Diff line change
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::*;

// FIXME #34229 duplicated errors
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/range_traits-6.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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_gate.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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