Skip to content

Commit f338054

Browse files
committed
Add regression test
As well as matching error outputs
1 parent d08eb98 commit f338054

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![feature(const_generics)]
2+
#![allow(incomplete_features)]
3+
4+
pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>;
5+
pub struct Condition<const CONDITION: bool>;
6+
pub trait True {}
7+
8+
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
9+
Condition<{ LHS <= RHS }>: True
10+
//~^ Error constant expression depends on a generic parameter
11+
{
12+
}
13+
impl True for Condition<true> {}
14+
15+
struct S<const I: u32, const J: u32>;
16+
impl<const I: u32, const J: u32> S<I, J>
17+
where
18+
IsLessOrEqual<I, 8>: True,
19+
IsLessOrEqual<J, 8>: True,
20+
IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
21+
//~^ Error constant expression depends on a generic parameter
22+
//~| Error constant expression depends on a generic parameter
23+
//~| Error constant expression depends on a generic parameter
24+
//~| Error constant expression depends on a generic parameter
25+
// Condition<{ 8 - I <= 8 - J }>: True,
26+
{
27+
fn print() {
28+
println!("I {} J {}", I, J);
29+
}
30+
}
31+
32+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error: constant expression depends on a generic parameter
2+
--> $DIR/issue-72787.rs:9:32
3+
|
4+
LL | Condition<{ LHS <= RHS }>: True
5+
| ^^^^
6+
|
7+
= note: this may fail depending on what value the parameter takes
8+
9+
error: constant expression depends on a generic parameter
10+
--> $DIR/issue-72787.rs:20:42
11+
|
12+
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
13+
| ^^^^
14+
|
15+
= note: this may fail depending on what value the parameter takes
16+
17+
error: constant expression depends on a generic parameter
18+
--> $DIR/issue-72787.rs:20:42
19+
|
20+
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
21+
| ^^^^
22+
|
23+
= note: this may fail depending on what value the parameter takes
24+
25+
error: constant expression depends on a generic parameter
26+
--> $DIR/issue-72787.rs:20:42
27+
|
28+
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
29+
| ^^^^
30+
|
31+
= note: this may fail depending on what value the parameter takes
32+
33+
error: constant expression depends on a generic parameter
34+
--> $DIR/issue-72787.rs:20:42
35+
|
36+
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
37+
| ^^^^
38+
|
39+
= note: this may fail depending on what value the parameter takes
40+
41+
error: aborting due to 5 previous errors
42+

0 commit comments

Comments
 (0)