1
Fork 0

Add const generics test for all range types.

In addition to the regression test of `RangeInclusive` for #70155, now all range types are checked for usability within const generics:

- `RangeFrom`
- `RangeFull`
- `RangeToInclusive`
- `RangeTo`
- `Range`

The test are moved from `test\ui\const-generics\issues\issue-70155` to `test\ui\const-generics\std\range` in anticipation of future similar tests for std types.
This commit is contained in:
CDirkx 2020-03-23 19:16:12 +01:00
parent bd1df44057
commit f080f944f1
6 changed files with 58 additions and 2 deletions

View file

@ -0,0 +1,11 @@
// check-pass
#![allow(incomplete_features)]
#![feature(const_generics)]
// `RangeFrom` should be usable within const generics:
struct S<const R: std::ops::RangeFrom<usize>>;
const C : S<{ 0 .. }> = S;
pub fn main() {}

View file

@ -0,0 +1,11 @@
// check-pass
#![allow(incomplete_features)]
#![feature(const_generics)]
// `RangeFull` should be usable within const generics:
struct S<const R: std::ops::RangeFull>;
const C : S<{ .. }> = S;
pub fn main() {}

View file

@ -2,8 +2,9 @@
#![allow(incomplete_features)]
#![feature(const_generics)]
// Regression test for #70155:
// `RangeInclusive` should be usable with const generics
// Regression test for #70155
// `RangeInclusive` should be usable within const generics:
struct S<const R: std::ops::RangeInclusive<usize>>;

View file

@ -0,0 +1,11 @@
// check-pass
#![allow(incomplete_features)]
#![feature(const_generics)]
// `RangeToInclusive` should be usable within const generics:
struct S<const R: std::ops::RangeToInclusive<usize>>;
const C : S<{ ..= 999 }> = S;
pub fn main() {}

View file

@ -0,0 +1,11 @@
// check-pass
#![allow(incomplete_features)]
#![feature(const_generics)]
// `RangeTo` should be usable within const generics:
struct S<const R: std::ops::RangeTo<usize>>;
const C : S<{ .. 1000 }> = S;
pub fn main() {}

View file

@ -0,0 +1,11 @@
// check-pass
#![allow(incomplete_features)]
#![feature(const_generics)]
// `Range` should be usable within const generics:
struct S<const R: std::ops::Range<usize>>;
const C : S<{ 0 .. 1000 }> = S;
pub fn main() {}