Skip to content

Commit cd14b73

Browse files
committed
Auto merge of rust-lang#154459 - tgross35:destabilize-range-iter-remainder, r=scottmcm
core: Destabilize beta-stable `RangeInclusiveIter::remainder` Destabilize `RangeInclusiveIter::remainder` and move `{RangeIter,RangefromIter}::remainder` to the `new_range_api` feature gate. Original tracking issue: rust-lang#125687 New tracking issue: rust-lang#154458 Discussion: https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/.60RangeFrom.3A.3Aremainder.60.20possible.20panic/with/582108913
2 parents 584d32e + 0bb3fe3 commit cd14b73

7 files changed

Lines changed: 31 additions & 12 deletions

File tree

library/core/src/range/iter.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ use crate::{intrinsics, mem};
1111
pub struct RangeIter<A>(legacy::Range<A>);
1212

1313
impl<A> RangeIter<A> {
14-
#[unstable(feature = "new_range_api", issue = "125687")]
14+
#[unstable(feature = "new_range_remainder", issue = "154458")]
1515
/// Returns the remainder of the range being iterated over.
1616
///
1717
/// # Examples
18+
///
1819
/// ```
1920
/// #![feature(new_range_api)]
21+
/// #![feature(new_range_remainder)]
22+
///
2023
/// let range = core::range::Range::from(3..11);
2124
/// let mut iter = range.into_iter();
2225
/// assert_eq!(iter.clone().remainder(), range);
@@ -175,7 +178,10 @@ impl<A: Step> RangeInclusiveIter<A> {
175178
/// If the iterator is exhausted or empty, returns `None`.
176179
///
177180
/// # Examples
181+
///
178182
/// ```
183+
/// #![feature(new_range_remainder)]
184+
///
179185
/// let range = core::range::RangeInclusive::from(3..=11);
180186
/// let mut iter = range.into_iter();
181187
/// assert_eq!(iter.clone().remainder().unwrap(), range);
@@ -184,7 +190,7 @@ impl<A: Step> RangeInclusiveIter<A> {
184190
/// iter.by_ref().for_each(drop);
185191
/// assert!(iter.remainder().is_none());
186192
/// ```
187-
#[stable(feature = "new_range_inclusive_api", since = "1.95.0")]
193+
#[unstable(feature = "new_range_remainder", issue = "154458")]
188194
pub fn remainder(self) -> Option<RangeInclusive<A>> {
189195
if self.0.is_empty() {
190196
return None;
@@ -330,8 +336,10 @@ impl<A: Step> RangeFromIter<A> {
330336
/// Returns the remainder of the range being iterated over.
331337
///
332338
/// # Examples
339+
///
333340
/// ```
334-
/// #![feature(new_range_api)]
341+
/// #![feature(new_range_remainder)]
342+
///
335343
/// let range = core::range::RangeFrom::from(3..);
336344
/// let mut iter = range.into_iter();
337345
/// assert_eq!(iter.clone().remainder(), range);
@@ -340,7 +348,7 @@ impl<A: Step> RangeFromIter<A> {
340348
/// ```
341349
#[inline]
342350
#[rustc_inherit_overflow_checks]
343-
#[unstable(feature = "new_range_api", issue = "125687")]
351+
#[unstable(feature = "new_range_remainder", issue = "154458")]
344352
pub fn remainder(self) -> RangeFrom<A> {
345353
// Need to handle this case even if overflow-checks are disabled,
346354
// because a `RangeFromIter` could be exhausted in a crate with

tests/codegen-llvm/fromrangeiter-overflow-checks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#![crate_type = "lib"]
1313
#![feature(new_range_api)]
14+
#![feature(new_range_remainder)]
1415

1516
use std::range::RangeFrom;
1617

tests/ui/iterators/rangefrom-overflow-debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ needs-unwind
33
//@ compile-flags: -O -C debug_assertions=yes
44

5-
#![feature(new_range_api)]
5+
#![feature(new_range_remainder)]
66

77
use std::panic;
88

tests/ui/iterators/rangefrom-overflow-ndebug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ run-pass
22
//@ compile-flags: -O -C debug_assertions=no
33

4-
#![feature(new_range_api)]
4+
#![feature(new_range_remainder)]
55

66
fn main() {
77
let mut it = core::range::RangeFrom::from(u8::MAX..).into_iter();

tests/ui/iterators/rangefrom-overflow-overflow-checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ needs-unwind
33
//@ compile-flags: -O -C overflow-checks=yes
44

5-
#![feature(new_range_api)]
5+
#![feature(new_range_remainder)]
66

77
use std::panic;
88

tests/ui/range/new_range_stability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn range_inclusive(mut r: RangeInclusive<usize>) {
1919

2020
let mut i = r.into_iter();
2121
i.next();
22-
i.remainder();
22+
i.remainder(); //~ ERROR unstable
2323
}
2424

2525
fn range_to_inclusive(mut r: RangeToInclusive<usize>) {

tests/ui/range/new_range_stability.stderr

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,26 @@ LL | use std::range::RangeIter;
2828
= help: add `#![feature(new_range_api)]` to the crate attributes to enable
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

31-
error[E0658]: use of unstable library feature `new_range_api`
31+
error[E0658]: use of unstable library feature `new_range_remainder`
32+
--> $DIR/new_range_stability.rs:22:7
33+
|
34+
LL | i.remainder();
35+
| ^^^^^^^^^
36+
|
37+
= note: see issue #154458 <https://github.com/rust-lang/rust/issues/154458> for more information
38+
= help: add `#![feature(new_range_remainder)]` to the crate attributes to enable
39+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
40+
41+
error[E0658]: use of unstable library feature `new_range_remainder`
3242
--> $DIR/new_range_stability.rs:43:7
3343
|
3444
LL | i.remainder();
3545
| ^^^^^^^^^
3646
|
37-
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
38-
= help: add `#![feature(new_range_api)]` to the crate attributes to enable
47+
= note: see issue #154458 <https://github.com/rust-lang/rust/issues/154458> for more information
48+
= help: add `#![feature(new_range_remainder)]` to the crate attributes to enable
3949
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
4050

41-
error: aborting due to 4 previous errors
51+
error: aborting due to 5 previous errors
4252

4353
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)