From 526945915b3745168d192bcb2c7fb1428815a9bb Mon Sep 17 00:00:00 2001 From: Bastian Kauschke Date: Wed, 15 Jul 2020 15:14:33 +0200 Subject: [PATCH] add lazy normalization regression tests --- .../trait-resolution-breakage.rs | 18 ++++++++++++++++++ .../unevaluated-consts.rs | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs create mode 100644 src/test/ui/lazy_normalization_consts/unevaluated-consts.rs diff --git a/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs b/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs new file mode 100644 index 0000000000000..df1c99e8671e8 --- /dev/null +++ b/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs @@ -0,0 +1,18 @@ +// check-pass + +trait Trait { + const ASSOC_CONST: usize = 0; +} + +impl Trait<()> for u8 {} + +// `u8::ASSOC_CONST` is resolved today, but will be ambiguous +// under lazy normalization. +fn foo() -> [(T, U); u8::ASSOC_CONST] +where + u8: Trait + Trait, +{ + todo!() +} + +fn main() {} diff --git a/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs b/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs new file mode 100644 index 0000000000000..3f90d22ae2d22 --- /dev/null +++ b/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs @@ -0,0 +1,18 @@ +// check-pass + +// If we allow the parent generics here without using lazy normalization +// this results in a cycle error. +struct Foo(T, U); + +impl From<[u8; 1 + 1]> for Foo { + fn from(value: [u8; 1 + 1]) -> Foo { + todo!(); + } +} + +fn break_me() +where + [u8; 1 + 1]: From<[u8; 1 + 1]> +{} + +fn main() {}