Skip to content

Commit 3926453

Browse files
committed
Auto merge of #47813 - kennytm:stable-incl-range, r=nrc
Stabilize inclusive range (`..=`) Stabilize the followings: * `inclusive_range` — The `std::ops::RangeInclusive` and `std::ops::RangeInclusiveTo` types, except its fields (tracked by #49022 separately). * `inclusive_range_syntax` — The `a..=b` and `..=b` expression syntax * `dotdoteq_in_patterns` — Using `a..=b` in a pattern cc #28237 r? @rust-lang/lang
2 parents ff2d506 + 939cfa2 commit 3926453

39 files changed

+187
-256
lines changed

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

-20
This file was deleted.

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
#![feature(fundamental)]
9999
#![feature(generic_param_attrs)]
100100
#![feature(i128_type)]
101-
#![feature(inclusive_range)]
102101
#![feature(iter_rfold)]
103102
#![feature(lang_items)]
104103
#![feature(needs_allocator)]
@@ -125,6 +124,7 @@
125124
#![feature(on_unimplemented)]
126125
#![feature(exact_chunks)]
127126
#![feature(pointer_methods)]
127+
#![feature(inclusive_range_fields)]
128128

129129
#![cfg_attr(not(test), feature(fn_traits, placement_new_protocol, swap_with_slice, i128))]
130130
#![cfg_attr(test, feature(test, box_heap))]

src/liballoc/range.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<T> RangeArgument<T> for Range<T> {
103103
}
104104
}
105105

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

116-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
116+
#[stable(feature = "inclusive_range", since = "1.26.0")]
117117
impl<T> RangeArgument<T> for RangeToInclusive<T> {
118118
fn start(&self) -> Bound<&T> {
119119
Unbounded

src/liballoc/string.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ impl ops::Index<ops::RangeFull> for String {
19501950
unsafe { str::from_utf8_unchecked(&self.vec) }
19511951
}
19521952
}
1953-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
1953+
#[stable(feature = "inclusive_range", since = "1.26.0")]
19541954
impl ops::Index<ops::RangeInclusive<usize>> for String {
19551955
type Output = str;
19561956

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

@@ -1997,14 +1997,14 @@ impl ops::IndexMut<ops::RangeFull> for String {
19971997
unsafe { str::from_utf8_unchecked_mut(&mut *self.vec) }
19981998
}
19991999
}
2000-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
2000+
#[stable(feature = "inclusive_range", since = "1.26.0")]
20012001
impl ops::IndexMut<ops::RangeInclusive<usize>> for String {
20022002
#[inline]
20032003
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
20042004
IndexMut::index_mut(&mut **self, index)
20052005
}
20062006
}
2007-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
2007+
#[stable(feature = "inclusive_range", since = "1.26.0")]
20082008
impl ops::IndexMut<ops::RangeToInclusive<usize>> for String {
20092009
#[inline]
20102010
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {

src/liballoc/tests/lib.rs

+2-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)]
@@ -30,6 +30,7 @@
3030
#![feature(unboxed_closures)]
3131
#![feature(unicode)]
3232
#![feature(exact_chunks)]
33+
#![feature(inclusive_range_fields)]
3334

3435
extern crate alloc_system;
3536
extern crate std_unicode;

src/libcore/iter/range.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ macro_rules! range_exact_iter_impl {
186186

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

203201
macro_rules! range_incl_trusted_len_impl {
204202
($($t:ty)*) => ($(
205-
#[unstable(feature = "inclusive_range",
206-
reason = "recently added, follows RFC",
207-
issue = "28237")]
203+
#[stable(feature = "inclusive_range", since = "1.26.0")]
208204
unsafe impl TrustedLen for ops::RangeInclusive<$t> { }
209205
)*)
210206
}
@@ -328,7 +324,7 @@ impl<A: Step> FusedIterator for ops::RangeFrom<A> {}
328324
#[unstable(feature = "trusted_len", issue = "37572")]
329325
unsafe impl<A: Step> TrustedLen for ops::RangeFrom<A> {}
330326

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

@@ -422,7 +418,7 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
422418
}
423419
}
424420

425-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
421+
#[stable(feature = "inclusive_range", since = "1.26.0")]
426422
impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> {
427423
#[inline]
428424
fn next_back(&mut self) -> Option<A> {

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/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ pub use self::index::{Index, IndexMut};
191191
#[stable(feature = "rust1", since = "1.0.0")]
192192
pub use self::range::{Range, RangeFrom, RangeFull, RangeTo};
193193

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

197197
#[unstable(feature = "try_trait", issue = "42327")]

src/libcore/ops/range.rs

+14-25
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,7 +283,7 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
283283
/// # Examples
284284
///
285285
/// ```
286-
/// #![feature(inclusive_range,inclusive_range_syntax)]
286+
/// #![feature(inclusive_range_fields)]
287287
///
288288
/// assert_eq!((3..=5), std::ops::RangeInclusive { start: 3, end: 5 });
289289
/// assert_eq!(3 + 4 + 5, (3..=5).sum());
@@ -293,21 +293,17 @@ impl<Idx: PartialOrd<Idx>> RangeTo<Idx> {
293293
/// assert_eq!(arr[1..=2], [ 1,2 ]); // RangeInclusive
294294
/// ```
295295
#[derive(Clone, PartialEq, Eq, Hash)] // not Copy -- see #27186
296-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
296+
#[stable(feature = "inclusive_range", since = "1.26.0")]
297297
pub struct RangeInclusive<Idx> {
298298
/// The lower bound of the range (inclusive).
299-
#[unstable(feature = "inclusive_range",
300-
reason = "recently added, follows RFC",
301-
issue = "28237")]
299+
#[unstable(feature = "inclusive_range_fields", issue = "49022")]
302300
pub start: Idx,
303301
/// The upper bound of the range (inclusive).
304-
#[unstable(feature = "inclusive_range",
305-
reason = "recently added, follows RFC",
306-
issue = "28237")]
302+
#[unstable(feature = "inclusive_range_fields", issue = "49022")]
307303
pub end: Idx,
308304
}
309305

310-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
306+
#[stable(feature = "inclusive_range", since = "1.26.0")]
311307
impl<Idx: fmt::Debug> fmt::Debug for RangeInclusive<Idx> {
312308
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
313309
write!(fmt, "{:?}..={:?}", self.start, self.end)
@@ -320,7 +316,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
320316
/// # Examples
321317
///
322318
/// ```
323-
/// #![feature(range_contains,inclusive_range_syntax)]
319+
/// #![feature(range_contains)]
324320
///
325321
/// assert!(!(3..=5).contains(2));
326322
/// assert!( (3..=5).contains(3));
@@ -341,7 +337,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
341337
/// # Examples
342338
///
343339
/// ```
344-
/// #![feature(range_is_empty,inclusive_range_syntax)]
340+
/// #![feature(range_is_empty)]
345341
///
346342
/// assert!(!(3..=5).is_empty());
347343
/// assert!(!(3..=3).is_empty());
@@ -351,7 +347,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
351347
/// The range is empty if either side is incomparable:
352348
///
353349
/// ```
354-
/// #![feature(range_is_empty,inclusive_range_syntax)]
350+
/// #![feature(range_is_empty)]
355351
///
356352
/// use std::f32::NAN;
357353
/// assert!(!(3.0..=5.0).is_empty());
@@ -362,7 +358,7 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
362358
/// This method returns `true` after iteration has finished:
363359
///
364360
/// ```
365-
/// #![feature(range_is_empty,inclusive_range_syntax)]
361+
/// #![feature(range_is_empty)]
366362
///
367363
/// let mut r = 3..=5;
368364
/// for _ in r.by_ref() {}
@@ -385,16 +381,13 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
385381
/// The `..=end` syntax is a `RangeToInclusive`:
386382
///
387383
/// ```
388-
/// #![feature(inclusive_range,inclusive_range_syntax)]
389384
/// assert_eq!((..=5), std::ops::RangeToInclusive{ end: 5 });
390385
/// ```
391386
///
392387
/// It does not have an [`IntoIterator`] implementation, so you can't use it in a
393388
/// `for` loop directly. This won't compile:
394389
///
395390
/// ```compile_fail,E0277
396-
/// #![feature(inclusive_range_syntax)]
397-
///
398391
/// // error[E0277]: the trait bound `std::ops::RangeToInclusive<{integer}>:
399392
/// // std::iter::Iterator` is not satisfied
400393
/// for i in ..=5 {
@@ -406,8 +399,6 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
406399
/// array elements up to and including the index indicated by `end`.
407400
///
408401
/// ```
409-
/// #![feature(inclusive_range_syntax)]
410-
///
411402
/// let arr = [0, 1, 2, 3];
412403
/// assert_eq!(arr[ ..=2], [0,1,2 ]); // RangeToInclusive
413404
/// assert_eq!(arr[1..=2], [ 1,2 ]);
@@ -417,16 +408,14 @@ impl<Idx: PartialOrd<Idx>> RangeInclusive<Idx> {
417408
/// [`Iterator`]: ../iter/trait.IntoIterator.html
418409
/// [slicing index]: ../slice/trait.SliceIndex.html
419410
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
420-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
411+
#[stable(feature = "inclusive_range", since = "1.26.0")]
421412
pub struct RangeToInclusive<Idx> {
422413
/// The upper bound of the range (inclusive)
423-
#[unstable(feature = "inclusive_range",
424-
reason = "recently added, follows RFC",
425-
issue = "28237")]
414+
#[stable(feature = "inclusive_range", since = "1.26.0")]
426415
pub end: Idx,
427416
}
428417

429-
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
418+
#[stable(feature = "inclusive_range", since = "1.26.0")]
430419
impl<Idx: fmt::Debug> fmt::Debug for RangeToInclusive<Idx> {
431420
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
432421
write!(fmt, "..={:?}", self.end)
@@ -440,7 +429,7 @@ impl<Idx: PartialOrd<Idx>> RangeToInclusive<Idx> {
440429
/// # Examples
441430
///
442431
/// ```
443-
/// #![feature(range_contains,inclusive_range_syntax)]
432+
/// #![feature(range_contains)]
444433
///
445434
/// assert!( (..=5).contains(-1_000_000_000));
446435
/// assert!( (..=5).contains(5));

src/libcore/slice/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ impl<T> SliceIndex<[T]> for ops::RangeFull {
10391039
}
10401040

10411041

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

@@ -1080,7 +1080,7 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
10801080
}
10811081
}
10821082

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

src/libcore/str/mod.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -1779,9 +1779,7 @@ mod traits {
17791779
}
17801780
}
17811781

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

@@ -1791,9 +1789,7 @@ mod traits {
17911789
}
17921790
}
17931791

1794-
#[unstable(feature = "inclusive_range",
1795-
reason = "recently added, follows RFC",
1796-
issue = "28237")]
1792+
#[stable(feature = "inclusive_range", since = "1.26.0")]
17971793
impl ops::Index<ops::RangeToInclusive<usize>> for str {
17981794
type Output = str;
17991795

@@ -1803,18 +1799,14 @@ mod traits {
18031799
}
18041800
}
18051801

1806-
#[unstable(feature = "inclusive_range",
1807-
reason = "recently added, follows RFC",
1808-
issue = "28237")]
1802+
#[stable(feature = "inclusive_range", since = "1.26.0")]
18091803
impl ops::IndexMut<ops::RangeInclusive<usize>> for str {
18101804
#[inline]
18111805
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut str {
18121806
index.index_mut(self)
18131807
}
18141808
}
1815-
#[unstable(feature = "inclusive_range",
1816-
reason = "recently added, follows RFC",
1817-
issue = "28237")]
1809+
#[stable(feature = "inclusive_range", since = "1.26.0")]
18181810
impl ops::IndexMut<ops::RangeToInclusive<usize>> for str {
18191811
#[inline]
18201812
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut str {
@@ -1997,9 +1989,7 @@ mod traits {
19971989
}
19981990
}
19991991

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

20432033

20442034

2045-
#[unstable(feature = "inclusive_range",
2046-
reason = "recently added, follows RFC",
2047-
issue = "28237")]
2035+
#[stable(feature = "inclusive_range", since = "1.26.0")]
20482036
impl SliceIndex<str> for ops::RangeToInclusive<usize> {
20492037
type Output = str;
20502038
#[inline]

0 commit comments

Comments
 (0)