Skip to content
Open
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
20 changes: 8 additions & 12 deletions library/core/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ use crate::hash::Hash;

mod iter;

#[unstable(feature = "new_range_api_legacy", issue = "125687")]
#[stable(feature = "new_range_api_legacy", since = "CURRENT_RUSTC_VERSION")]
pub mod legacy;

use core::ops::Bound::{self, Excluded, Included, Unbounded};

#[doc(inline)]
#[stable(feature = "new_range_from_api", since = "1.96.0")]
pub use iter::RangeFromIter;
Expand All @@ -33,19 +35,13 @@ pub use iter::RangeInclusiveIter;
#[stable(feature = "new_range_api", since = "1.96.0")]
pub use iter::RangeIter;

// FIXME(#125687): re-exports temporarily removed
// Because re-exports of stable items (Bound, RangeBounds, RangeFull, RangeTo)
// can't be made unstable.
//
// #[doc(inline)]
// #[unstable(feature = "new_range_api", issue = "125687")]
// pub use crate::iter::Step;
// #[doc(inline)]
// #[unstable(feature = "new_range_api", issue = "125687")]
// pub use crate::ops::{Bound, IntoBounds, OneSidedRange, RangeBounds, RangeFull, RangeTo};
use crate::iter::Step;
use crate::ops::Bound::{self, Excluded, Included, Unbounded};
// FIXME(one_sided_range): These types should move into this module.
// FIXME(range_into_bounds): Ditto. Also consider re-exporting `RangeBounds` and related.
use crate::ops::{IntoBounds, OneSidedRange, OneSidedRangeBound, RangeBounds};
#[doc(inline)]
#[stable(feature = "new_range_api_exports", since = "CURRENT_RUSTC_VERSION")]
pub use crate::ops::{RangeFull, RangeTo};

/// A (half-open) range bounded inclusively below and exclusively above.
///
Expand Down
1 change: 1 addition & 0 deletions library/core/src/range/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
//! The types here are equivalent to those in [`core::ops`].
#[doc(inline)]
#[stable(feature = "new_range_api_legacy", since = "CURRENT_RUSTC_VERSION")]
pub use crate::ops::{Range, RangeFrom, RangeInclusive, RangeToInclusive};
8 changes: 3 additions & 5 deletions tests/ui/new-range/disabled.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
//! Without the `new_range` feature enabled, `..` syntax resolves to the legacy types.
//@ check-pass

#![feature(new_range_api_legacy)]

fn main() {
// Unchanged
let a: core::ops::RangeFull = ..;
let b: core::ops::RangeTo<u8> = ..2;

// FIXME(#125687): re-exports temporarily removed
// let _: core::range::RangeFull = a;
// let _: core::range::RangeTo<u8> = b;
let _: core::range::RangeFull = a;
let _: core::range::RangeTo<u8> = b;

// Changed
let a: core::range::legacy::RangeFrom<u8> = 1..;
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/new-range/enabled.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! With the `new_range` feature enabled, `..` syntax resolves to the new range types.
//@ check-pass

#![feature(new_range)]
Expand All @@ -7,9 +8,8 @@ fn main() {
let a: core::ops::RangeFull = ..;
let b: core::ops::RangeTo<u8> = ..2;

// FIXME(#125687): re-exports temporarily removed
// let _: core::range::RangeFull = a;
// let _: core::range::RangeTo<u8> = b;
let _: core::range::RangeFull = a;
let _: core::range::RangeTo<u8> = b;

// Changed
let a: core::range::RangeFrom<u8> = 1..;
Expand Down
5 changes: 1 addition & 4 deletions tests/ui/range/new_range_stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::range::{
RangeFrom,
RangeFromIter,
Range,
legacy,
};

fn range_inclusive(mut r: RangeInclusive<usize>) {
Expand Down Expand Up @@ -60,8 +61,4 @@ fn range(mut r: Range<usize>) {
i.remainder(); //~ ERROR unstable
}

// Unstable module

use std::range::legacy; //~ ERROR unstable

fn main() {}
18 changes: 4 additions & 14 deletions tests/ui/range/new_range_stability.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
error[E0658]: use of unstable library feature `new_range_api_legacy`
--> $DIR/new_range_stability.rs:65:5
|
LL | use std::range::legacy;
| ^^^^^^^^^^^^^^^^^^
|
= note: see issue #125687 <https://github.com/rust-lang/rust/issues/125687> for more information
= help: add `#![feature(new_range_api_legacy)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `new_range_remainder`
--> $DIR/new_range_stability.rs:23:7
--> $DIR/new_range_stability.rs:24:7
|
LL | i.remainder();
| ^^^^^^^^^
Expand All @@ -19,7 +9,7 @@ LL | i.remainder();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `new_range_remainder`
--> $DIR/new_range_stability.rs:44:7
--> $DIR/new_range_stability.rs:45:7
|
LL | i.remainder();
| ^^^^^^^^^
Expand All @@ -29,7 +19,7 @@ LL | i.remainder();
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: use of unstable library feature `new_range_remainder`
--> $DIR/new_range_stability.rs:60:7
--> $DIR/new_range_stability.rs:61:7
|
LL | i.remainder();
| ^^^^^^^^^
Expand All @@ -38,6 +28,6 @@ LL | i.remainder();
= help: add `#![feature(new_range_remainder)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

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