From f3380547138df05d4ac23e4a905756cfbe76fc79 Mon Sep 17 00:00:00 2001 From: kadmin Date: Tue, 4 Aug 2020 22:14:27 +0000 Subject: [PATCH] Add regression test As well as matching error outputs --- .../ui/const-generics/issues/issue-72787.rs | 32 ++++++++++++++ .../const-generics/issues/issue-72787.stderr | 42 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-72787.rs create mode 100644 src/test/ui/const-generics/issues/issue-72787.stderr diff --git a/src/test/ui/const-generics/issues/issue-72787.rs b/src/test/ui/const-generics/issues/issue-72787.rs new file mode 100644 index 00000000000..a368c226ec3 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-72787.rs @@ -0,0 +1,32 @@ +#![feature(const_generics)] +#![allow(incomplete_features)] + +pub struct IsLessOrEqual; +pub struct Condition; +pub trait True {} + +impl True for IsLessOrEqual where + Condition<{ LHS <= RHS }>: True +//~^ Error constant expression depends on a generic parameter +{ +} +impl True for Condition {} + +struct S; +impl S +where + IsLessOrEqual: True, + IsLessOrEqual: 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() {} diff --git a/src/test/ui/const-generics/issues/issue-72787.stderr b/src/test/ui/const-generics/issues/issue-72787.stderr new file mode 100644 index 00000000000..ed892e46bbb --- /dev/null +++ b/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 +