about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-02-11 11:15:56 +0530
committerGitHub <noreply@github.com>2023-02-11 11:15:56 +0530
commit2228c86bad4f2c35b323b764d1bc42407a11b010 (patch)
tree6b3551ae57d34dc096a0789508fc85c592fe37ea
parent27454012c1c930e9996020fc7140f95576ea0697 (diff)
parenta03da2bdeb7c7b466b7b4a9b361d1d19c171a589 (diff)
downloadrust-2228c86bad4f2c35b323b764d1bc42407a11b010.tar.gz
rust-2228c86bad4f2c35b323b764d1bc42407a11b010.zip
Rollup merge of #107857 - GuillaumeGomez:ui-test-impl-projections, r=oli-obk
Add ui test for implementation on projection

The error in full can be seen in https://github.com/rust-lang/rust/pull/107263 and is part of why the PR is blocked (it still requires the approval from the team for supporting it).

r? ``@oli-obk``
-rw-r--r--tests/ui/const-generics/wrong-normalization.rs19
-rw-r--r--tests/ui/const-generics/wrong-normalization.stderr11
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/const-generics/wrong-normalization.rs b/tests/ui/const-generics/wrong-normalization.rs
new file mode 100644
index 00000000000..f1ce317b3f7
--- /dev/null
+++ b/tests/ui/const-generics/wrong-normalization.rs
@@ -0,0 +1,19 @@
+// This test ensures that if implementation on projections is supported,
+// it doesn't end in very weird cycle error.
+
+#![crate_type = "lib"]
+
+pub trait Identity {
+    type Identity: ?Sized;
+}
+
+impl<T: ?Sized> Identity for T {
+    type Identity = Self;
+}
+
+pub struct I8<const F: i8>;
+
+impl <I8<{i8::MIN}> as Identity>::Identity {
+//~^ ERROR no nominal type found for inherent implementation
+    pub fn foo(&self) {}
+}
diff --git a/tests/ui/const-generics/wrong-normalization.stderr b/tests/ui/const-generics/wrong-normalization.stderr
new file mode 100644
index 00000000000..fb806bdb1e7
--- /dev/null
+++ b/tests/ui/const-generics/wrong-normalization.stderr
@@ -0,0 +1,11 @@
+error[E0118]: no nominal type found for inherent implementation
+  --> $DIR/wrong-normalization.rs:16:6
+   |
+LL | impl <I8<{i8::MIN}> as Identity>::Identity {
+   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type
+   |
+   = note: either implement a trait on it or create a newtype to wrap it instead
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0118`.