Skip to content

Commit 95eaadc

Browse files
committed
std::range
1 parent 6c1d960 commit 95eaadc

17 files changed

+42
-40
lines changed

library/std/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ pub use core::option;
530530
pub use core::pin;
531531
#[stable(feature = "rust1", since = "1.0.0")]
532532
pub use core::ptr;
533+
#[unstable(feature = "new_range_api", issue = "125687")]
534+
pub use core::range;
533535
#[stable(feature = "rust1", since = "1.0.0")]
534536
pub use core::result;
535537
#[stable(feature = "rust1", since = "1.0.0")]

tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
1919
scope 2 {
2020
debug x => _9;
2121
}
22-
scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
22+
scope 5 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) {
2323
}
2424
}
25-
scope 3 (inlined RangeInclusive::<u32>::new) {
25+
scope 3 (inlined std::ops::RangeInclusive::<u32>::new) {
2626
}
27-
scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) {
27+
scope 4 (inlined <std::ops::RangeInclusive<u32> as IntoIterator>::into_iter) {
2828
}
2929

3030
bb0: {
31-
_4 = RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false };
31+
_4 = std::ops::RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false };
3232
StorageLive(_5);
3333
_5 = copy _4;
3434
goto -> bb1;
@@ -37,7 +37,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
3737
bb1: {
3838
StorageLive(_7);
3939
_6 = &mut _5;
40-
_7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable];
40+
_7 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable];
4141
}
4242

4343
bb2: {

tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
1919
scope 2 {
2020
debug x => _9;
2121
}
22-
scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
22+
scope 5 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) {
2323
}
2424
}
25-
scope 3 (inlined RangeInclusive::<u32>::new) {
25+
scope 3 (inlined std::ops::RangeInclusive::<u32>::new) {
2626
}
27-
scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) {
27+
scope 4 (inlined <std::ops::RangeInclusive<u32> as IntoIterator>::into_iter) {
2828
}
2929

3030
bb0: {
31-
_4 = RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false };
31+
_4 = std::ops::RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false };
3232
StorageLive(_5);
3333
_5 = copy _4;
3434
goto -> bb1;
@@ -37,7 +37,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
3737
bb1: {
3838
StorageLive(_7);
3939
_6 = &mut _5;
40-
_7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8];
40+
_7 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8];
4141
}
4242

4343
bb2: {

tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// MIR for `range_inclusive_iter_next` after PreCodegen
22

3-
fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> {
3+
fn range_inclusive_iter_next(_1: &mut std::ops::RangeInclusive<u32>) -> Option<u32> {
44
debug it => _1;
55
let mut _0: std::option::Option<u32>;
6-
scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
6+
scope 1 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) {
77
}
88

99
bb0: {
10-
_0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind unreachable];
10+
_0 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind unreachable];
1111
}
1212

1313
bb1: {

tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// MIR for `range_inclusive_iter_next` after PreCodegen
22

3-
fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> {
3+
fn range_inclusive_iter_next(_1: &mut std::ops::RangeInclusive<u32>) -> Option<u32> {
44
debug it => _1;
55
let mut _0: std::option::Option<u32>;
6-
scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) {
6+
scope 1 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) {
77
}
88

99
bb0: {
10-
_0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind continue];
10+
_0 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind continue];
1111
}
1212

1313
bb1: {

tests/ui/const-generics/std/const-generics-range.full.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0741]: `std::ops::Range<usize>` must implement `ConstParamTy` to be used
44
LL | struct _Range<const R: std::ops::Range<usize>>;
55
| ^^^^^^^^^^^^^^^^^^^^^^
66

7-
error[E0741]: `RangeFrom<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter
7+
error[E0741]: `std::ops::RangeFrom<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter
88
--> $DIR/const-generics-range.rs:13:28
99
|
1010
LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
@@ -16,7 +16,7 @@ error[E0741]: `RangeFull` must implement `ConstParamTy` to be used as the type o
1616
LL | struct _RangeFull<const R: std::ops::RangeFull>;
1717
| ^^^^^^^^^^^^^^^^^^^
1818

19-
error[E0741]: `RangeInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter
19+
error[E0741]: `std::ops::RangeInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter
2020
--> $DIR/const-generics-range.rs:24:33
2121
|
2222
LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;

tests/ui/const-generics/std/const-generics-range.min.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
1010
LL + #![feature(adt_const_params)]
1111
|
1212

13-
error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter
13+
error: `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter
1414
--> $DIR/const-generics-range.rs:13:28
1515
|
1616
LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
@@ -34,7 +34,7 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more
3434
LL + #![feature(adt_const_params)]
3535
|
3636

37-
error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter
37+
error: `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic parameter
3838
--> $DIR/const-generics-range.rs:24:33
3939
|
4040
LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;

tests/ui/const-generics/std/const-generics-range.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const RANGE : _Range<{ 0 .. 1000 }> = _Range;
1111

1212
// `RangeFrom` should be usable within const generics:
1313
struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
14-
//[min]~^ ERROR `RangeFrom<usize>` is forbidden
14+
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden
1515
const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom;
1616

1717
// `RangeFull` should be usable within const generics:
@@ -22,7 +22,7 @@ const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull;
2222
// Regression test for #70155
2323
// `RangeInclusive` should be usable within const generics:
2424
struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
25-
//[min]~^ ERROR `RangeInclusive<usize>` is forbidden
25+
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden
2626
const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive;
2727

2828
// `RangeTo` should be usable within const generics:

tests/ui/issues/issue-76191.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LL | RANGE => {}
2121
| `RANGE` is interpreted as a constant, not a new binding
2222
|
2323
= note: expected type `i32`
24-
found struct `RangeInclusive<i32>`
24+
found struct `std::ops::RangeInclusive<i32>`
2525
help: you may want to move the range into the match block
2626
|
2727
LL | 0..=255 => {}
@@ -43,7 +43,7 @@ LL | RANGE2 => {}
4343
| `RANGE2` is interpreted as a constant, not a new binding
4444
|
4545
= note: expected type `i32`
46-
found struct `RangeInclusive<i32>`
46+
found struct `std::ops::RangeInclusive<i32>`
4747
= note: constants only support matching by type, if you meant to match against a range of values, consider using a range pattern like `min ..= max` in the match block
4848

4949
error: aborting due to 3 previous errors

tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fn main() {
66
let _ = (-10..=10).find(|x: &i32| x.signum() == 0);
77
//[current]~^ ERROR type mismatch in closure arguments
8-
//[next]~^^ ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found
8+
//[next]~^^ ERROR expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found
99
let _ = (-10..=10).find(|x: &i32| x.signum() == 0);
1010
//[current]~^ ERROR type mismatch in closure arguments
1111
//[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}`

0 commit comments

Comments
 (0)