From 7dd1b6a22fc7c98cc3e3daeaae3a51bc184fee34 Mon Sep 17 00:00:00 2001 From: kadmin Date: Tue, 4 Aug 2020 23:07:04 +0000 Subject: [PATCH] Add regression test --- .../ui/const-generics/issues/issue-64494.rs | 19 +++++++++++++++++++ .../const-generics/issues/issue-64494.stderr | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-64494.rs create mode 100644 src/test/ui/const-generics/issues/issue-64494.stderr diff --git a/src/test/ui/const-generics/issues/issue-64494.rs b/src/test/ui/const-generics/issues/issue-64494.rs new file mode 100644 index 0000000000000..4c755530b9979 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-64494.rs @@ -0,0 +1,19 @@ +#![feature(const_generics)] +#![allow(incomplete_features)] + +trait Foo { + const VAL: usize; +} + +trait MyTrait {} + +trait True {} +struct Is; +impl True for Is<{true}> {} + +impl MyTrait for T where Is<{T::VAL == 5}>: True {} +//~^ ERROR constant expression depends on a generic parameter +impl MyTrait for T where Is<{T::VAL == 6}>: True {} +//~^ ERROR constant expression depends on a generic parameter + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-64494.stderr b/src/test/ui/const-generics/issues/issue-64494.stderr new file mode 100644 index 0000000000000..30dca16964317 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-64494.stderr @@ -0,0 +1,18 @@ +error: constant expression depends on a generic parameter + --> $DIR/issue-64494.rs:14:53 + | +LL | impl MyTrait for T where Is<{T::VAL == 5}>: True {} + | ^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/issue-64494.rs:16:53 + | +LL | impl MyTrait for T where Is<{T::VAL == 6}>: True {} + | ^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors +