about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2020-07-17 14:09:16 -0700
committerGitHub <noreply@github.com>2020-07-17 14:09:16 -0700
commit344b5e06fabab3e0634866a810d5fc57fcaac616 (patch)
treecaad4c7ad1f2dc2fbbbfdebbfd04e6bee9548e92 /src
parentc9010d6e85b06ad8b337d2ae1ffc1554faffc7c0 (diff)
parent526945915b3745168d192bcb2c7fb1428815a9bb (diff)
downloadrust-344b5e06fabab3e0634866a810d5fc57fcaac616.tar.gz
rust-344b5e06fabab3e0634866a810d5fc57fcaac616.zip
Rollup merge of #74364 - lcnr:lazy-norm-tests, r=nikomatsakis
add lazy normalization regression tests

We previously didn't have simple tests which fail if we aren't careful around lazy normalization.

We now do.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs18
-rw-r--r--src/test/ui/lazy_normalization_consts/unevaluated-consts.rs18
2 files changed, 36 insertions, 0 deletions
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 00000000000..df1c99e8671
--- /dev/null
+++ b/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+trait Trait<T> {
+    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>() -> [(T, U); u8::ASSOC_CONST]
+where
+    u8: Trait<T> + Trait<U>,
+{
+    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 00000000000..3f90d22ae2d
--- /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>(T, U);
+
+impl<T> From<[u8; 1 + 1]> for Foo<T, [u8; 1 + 1]> {
+    fn from(value: [u8; 1 + 1]) -> Foo<T, [u8; 1 + 1]> {
+        todo!();
+    }
+}
+
+fn break_me<T>()
+where
+    [u8; 1 + 1]: From<[u8; 1 + 1]>
+{}
+
+fn main() {}