Skip to content

Commit

Permalink
Add const generics test for all range types.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CDirkx committed Mar 23, 2020
1 parent bd1df44 commit f080f94
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/std/range/const-generics-range-from.rs
Original file line number Diff line number Diff line change
@@ -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() {}
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/std/range/const-generics-range-full.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
Expand Up @@ -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>>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}
11 changes: 11 additions & 0 deletions src/test/ui/const-generics/std/range/const-generics-range-to.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions src/test/ui/const-generics/std/range/const-generics-range.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit f080f94

Please sign in to comment.