Skip to content

Commit

Permalink
Auto merge of #75165 - JulianKnodt:i72787, r=lcnr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 5, 2020
2 parents 8b84156 + f338054 commit ec9d524
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/test/ui/const-generics/issues/issue-72787.rs
@@ -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() {}
42 changes: 42 additions & 0 deletions src/test/ui/const-generics/issues/issue-72787.stderr
@@ -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

0 comments on commit ec9d524

Please sign in to comment.