Skip to content

Commit f080f94

Browse files
author
CDirkx
committed
Add const generics test for all range types.
In addition to the regression test of `RangeInclusive` for rust-lang#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.
1 parent bd1df44 commit f080f94

6 files changed

+58
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
#![allow(incomplete_features)]
3+
#![feature(const_generics)]
4+
5+
// `RangeFrom` should be usable within const generics:
6+
7+
struct S<const R: std::ops::RangeFrom<usize>>;
8+
9+
const C : S<{ 0 .. }> = S;
10+
11+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
#![allow(incomplete_features)]
3+
#![feature(const_generics)]
4+
5+
// `RangeFull` should be usable within const generics:
6+
7+
struct S<const R: std::ops::RangeFull>;
8+
9+
const C : S<{ .. }> = S;
10+
11+
pub fn main() {}

src/test/ui/const-generics/issues/issue-70155.rs src/test/ui/const-generics/std/range/const-generics-range-inclusive.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#![allow(incomplete_features)]
33
#![feature(const_generics)]
44

5-
// Regression test for #70155:
6-
// `RangeInclusive` should be usable with const generics
5+
// Regression test for #70155
6+
7+
// `RangeInclusive` should be usable within const generics:
78

89
struct S<const R: std::ops::RangeInclusive<usize>>;
910

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
#![allow(incomplete_features)]
3+
#![feature(const_generics)]
4+
5+
// `RangeToInclusive` should be usable within const generics:
6+
7+
struct S<const R: std::ops::RangeToInclusive<usize>>;
8+
9+
const C : S<{ ..= 999 }> = S;
10+
11+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
#![allow(incomplete_features)]
3+
#![feature(const_generics)]
4+
5+
// `RangeTo` should be usable within const generics:
6+
7+
struct S<const R: std::ops::RangeTo<usize>>;
8+
9+
const C : S<{ .. 1000 }> = S;
10+
11+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// check-pass
2+
#![allow(incomplete_features)]
3+
#![feature(const_generics)]
4+
5+
// `Range` should be usable within const generics:
6+
7+
struct S<const R: std::ops::Range<usize>>;
8+
9+
const C : S<{ 0 .. 1000 }> = S;
10+
11+
pub fn main() {}

0 commit comments

Comments
 (0)