forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement unstable
new_range
feature
for RFC 3550, tracking issue rust-lang#123741
- Loading branch information
Showing
12 changed files
with
204 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# `new_range` | ||
|
||
The tracking issue for this feature is: [#123741] | ||
|
||
[#123741]: https://github.com/rust-lang/rust/issues/123741 | ||
|
||
--- | ||
|
||
Switch the syntaxes `a..`, `a..b`, and `a..=b` to resolve the new range types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(new_range_api)] | ||
|
||
fn main() { | ||
let a: core::range::RangeFrom<u8> = 1..; | ||
//~^ mismatched types | ||
let b: core::range::Range<u8> = 2..3; | ||
//~^ mismatched types | ||
let c: core::range::RangeInclusive<u8> = 4..=5; | ||
//~^ mismatched types | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/feature-gate-new_range.rs:4:41 | ||
| | ||
LL | let a: core::range::RangeFrom<u8> = 1..; | ||
| -------------------------- ^^^ expected `RangeFrom<u8>`, found `RangeFrom<{integer}>` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `std::range::RangeFrom<u8>` | ||
found struct `std::ops::RangeFrom<{integer}>` | ||
help: call `Into::into` on this expression to convert `std::ops::RangeFrom<{integer}>` into `std::range::RangeFrom<u8>` | ||
| | ||
LL | let a: core::range::RangeFrom<u8> = 1...into(); | ||
| +++++++ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/feature-gate-new_range.rs:6:37 | ||
| | ||
LL | let b: core::range::Range<u8> = 2..3; | ||
| ---------------------- ^^^^ expected `Range<u8>`, found `Range<{integer}>` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `std::range::Range<u8>` | ||
found struct `std::ops::Range<{integer}>` | ||
help: call `Into::into` on this expression to convert `std::ops::Range<{integer}>` into `std::range::Range<u8>` | ||
| | ||
LL | let b: core::range::Range<u8> = 2..3.into(); | ||
| +++++++ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/feature-gate-new_range.rs:8:46 | ||
| | ||
LL | let c: core::range::RangeInclusive<u8> = 4..=5; | ||
| ------------------------------- ^^^^^ expected `RangeInclusive<u8>`, found `RangeInclusive<{integer}>` | ||
| | | ||
| expected due to this | ||
| | ||
= note: expected struct `std::range::RangeInclusive<u8>` | ||
found struct `std::ops::RangeInclusive<{integer}>` | ||
help: call `Into::into` on this expression to convert `std::ops::RangeInclusive<{integer}>` into `std::range::RangeInclusive<u8>` | ||
| | ||
LL | let c: core::range::RangeInclusive<u8> = 4..=5.into(); | ||
| +++++++ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ check-pass | ||
|
||
#![feature(new_range_api)] | ||
|
||
fn main() { | ||
// Unchanged | ||
let a: core::range::RangeFull = ..; | ||
let b: core::range::RangeTo<u8> = ..2; | ||
let c: core::range::RangeToInclusive<u8> = ..=3; | ||
|
||
let _: core::ops::RangeFull = a; | ||
let _: core::ops::RangeTo<u8> = b; | ||
let _: core::ops::RangeToInclusive<u8> = c; | ||
|
||
// Changed | ||
let a: core::range::legacy::RangeFrom<u8> = 1..; | ||
let b: core::range::legacy::Range<u8> = 2..3; | ||
let c: core::range::legacy::RangeInclusive<u8> = 4..=5; | ||
|
||
let a: core::ops::RangeFrom<u8> = a; | ||
let b: core::ops::Range<u8> = b; | ||
let c: core::ops::RangeInclusive<u8> = c; | ||
|
||
let _: core::ops::RangeFrom<u8> = a.into_iter(); | ||
let _: core::ops::Range<u8> = b.into_iter(); | ||
let _: core::ops::RangeInclusive<u8> = c.into_iter(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ check-pass | ||
|
||
#![feature(new_range_api)] | ||
#![feature(new_range)] | ||
|
||
fn main() { | ||
// Unchanged | ||
let a: core::range::RangeFull = ..; | ||
let b: core::range::RangeTo<u8> = ..2; | ||
let c: core::range::RangeToInclusive<u8> = ..=3; | ||
|
||
let _: core::ops::RangeFull = a; | ||
let _: core::ops::RangeTo<u8> = b; | ||
let _: core::ops::RangeToInclusive<u8> = c; | ||
|
||
// Changed | ||
let a: core::range::RangeFrom<u8> = 1..; | ||
let b: core::range::Range<u8> = 2..3; | ||
let c: core::range::RangeInclusive<u8> = 4..=5; | ||
|
||
let _: core::range::IterRangeFrom<u8> = a.into_iter(); | ||
let _: core::range::IterRange<u8> = b.into_iter(); | ||
let _: core::range::IterRangeInclusive<u8> = c.into_iter(); | ||
} |