Auto merge of #75165 - JulianKnodt:i72787, r=lcnr

Add regression test for #72787

Add regression test for Issue #72787
Fixes #72787

~~Still waiting on running tests locally to bless the error output~~

r? @lcnr
This commit is contained in:
bors 2020-08-05 14:00:00 +00:00
commit ec9d5241f7
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#![feature(const_generics)]
#![allow(incomplete_features)]
pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>;
pub struct Condition<const CONDITION: bool>;
pub trait True {}
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
Condition<{ LHS <= RHS }>: True
//~^ Error constant expression depends on a generic parameter
{
}
impl True for Condition<true> {}
struct S<const I: u32, const J: u32>;
impl<const I: u32, const J: u32> S<I, J>
where
IsLessOrEqual<I, 8>: True,
IsLessOrEqual<J, 8>: True,
IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
//~^ Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
//~| Error constant expression depends on a generic parameter
// Condition<{ 8 - I <= 8 - J }>: True,
{
fn print() {
println!("I {} J {}", I, J);
}
}
fn main() {}

View File

@ -0,0 +1,42 @@
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:9:32
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^^
|
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
|
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
|
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
|
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> $DIR/issue-72787.rs:20:42
|
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^^^^
|
= note: this may fail depending on what value the parameter takes
error: aborting due to 5 previous errors