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:
parent
bd1df44057
commit
f080f944f1
6 changed files with 58 additions and 2 deletions
|
@ -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() {}
|
|
@ -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() {}
|
|
@ -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>>;
|
||||
|
|
@ -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() {}
|
|
@ -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() {}
|
11
src/test/ui/const-generics/std/range/const-generics-range.rs
Normal file
11
src/test/ui/const-generics/std/range/const-generics-range.rs
Normal 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() {}
|
Loading…
Add table
Add a link
Reference in a new issue