From 190582004b24086858282740f55280fe4143343f Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 15 May 2026 22:20:17 +0000 Subject: [PATCH 1/2] core: Stabilize `new_range_api_legacy` Newly stable API: core::range::legacy --- library/core/src/range.rs | 2 +- library/core/src/range/legacy.rs | 1 + tests/ui/new-range/disabled.rs | 3 +-- tests/ui/new-range/enabled.rs | 1 + tests/ui/range/new_range_stability.rs | 5 +---- tests/ui/range/new_range_stability.stderr | 18 ++++-------------- 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/library/core/src/range.rs b/library/core/src/range.rs index ade9a35b0ab33..9af910d3656ef 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -20,7 +20,7 @@ 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; #[doc(inline)] diff --git a/library/core/src/range/legacy.rs b/library/core/src/range/legacy.rs index aa11331382dd0..03f024354479d 100644 --- a/library/core/src/range/legacy.rs +++ b/library/core/src/range/legacy.rs @@ -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}; diff --git a/tests/ui/new-range/disabled.rs b/tests/ui/new-range/disabled.rs index 528c464117a13..2202ed23ff1d2 100644 --- a/tests/ui/new-range/disabled.rs +++ b/tests/ui/new-range/disabled.rs @@ -1,7 +1,6 @@ +//! 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 = ..; diff --git a/tests/ui/new-range/enabled.rs b/tests/ui/new-range/enabled.rs index 6d9a1259b7756..9f2833855b2fb 100644 --- a/tests/ui/new-range/enabled.rs +++ b/tests/ui/new-range/enabled.rs @@ -1,3 +1,4 @@ +//! With the `new_range` feature enabled, `..` syntax resolves to the new range types. //@ check-pass #![feature(new_range)] diff --git a/tests/ui/range/new_range_stability.rs b/tests/ui/range/new_range_stability.rs index 965be17efa747..cea1b33aac467 100644 --- a/tests/ui/range/new_range_stability.rs +++ b/tests/ui/range/new_range_stability.rs @@ -7,6 +7,7 @@ use std::range::{ RangeFrom, RangeFromIter, Range, + legacy, }; fn range_inclusive(mut r: RangeInclusive) { @@ -60,8 +61,4 @@ fn range(mut r: Range) { i.remainder(); //~ ERROR unstable } -// Unstable module - -use std::range::legacy; //~ ERROR unstable - fn main() {} diff --git a/tests/ui/range/new_range_stability.stderr b/tests/ui/range/new_range_stability.stderr index ac269a2b2227e..f280d15de1065 100644 --- a/tests/ui/range/new_range_stability.stderr +++ b/tests/ui/range/new_range_stability.stderr @@ -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 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(); | ^^^^^^^^^ @@ -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(); | ^^^^^^^^^ @@ -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(); | ^^^^^^^^^ @@ -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`. From 8d9f3da023eb1f5ef93e890826ada309134392f0 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 15 May 2026 22:44:46 +0000 Subject: [PATCH 2/2] core: Stabilize `RangeFull` and `RangeTo` re-exports in `core::range` Stabilized under `new_range_api_exports`. Newly stable API: core::range::RangeFull; core::range::RangeTo; --- library/core/src/range.rs | 18 +++++++----------- tests/ui/new-range/disabled.rs | 5 ++--- tests/ui/new-range/enabled.rs | 5 ++--- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/library/core/src/range.rs b/library/core/src/range.rs index 9af910d3656ef..6ca05f2f57e5c 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -23,6 +23,8 @@ mod iter; #[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; @@ -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. /// diff --git a/tests/ui/new-range/disabled.rs b/tests/ui/new-range/disabled.rs index 2202ed23ff1d2..25e35614c66a8 100644 --- a/tests/ui/new-range/disabled.rs +++ b/tests/ui/new-range/disabled.rs @@ -6,9 +6,8 @@ fn main() { let a: core::ops::RangeFull = ..; let b: core::ops::RangeTo = ..2; - // FIXME(#125687): re-exports temporarily removed - // let _: core::range::RangeFull = a; - // let _: core::range::RangeTo = b; + let _: core::range::RangeFull = a; + let _: core::range::RangeTo = b; // Changed let a: core::range::legacy::RangeFrom = 1..; diff --git a/tests/ui/new-range/enabled.rs b/tests/ui/new-range/enabled.rs index 9f2833855b2fb..ed227e088fcfa 100644 --- a/tests/ui/new-range/enabled.rs +++ b/tests/ui/new-range/enabled.rs @@ -8,9 +8,8 @@ fn main() { let a: core::ops::RangeFull = ..; let b: core::ops::RangeTo = ..2; - // FIXME(#125687): re-exports temporarily removed - // let _: core::range::RangeFull = a; - // let _: core::range::RangeTo = b; + let _: core::range::RangeFull = a; + let _: core::range::RangeTo = b; // Changed let a: core::range::RangeFrom = 1..;