From a03da2bdeb7c7b466b7b4a9b361d1d19c171a589 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 9 Feb 2023 20:45:01 +0100 Subject: [PATCH] Add test for implementation on projection --- .../ui/const-generics/wrong-normalization.rs | 19 +++++++++++++++++++ .../const-generics/wrong-normalization.stderr | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/ui/const-generics/wrong-normalization.rs create mode 100644 tests/ui/const-generics/wrong-normalization.stderr diff --git a/tests/ui/const-generics/wrong-normalization.rs b/tests/ui/const-generics/wrong-normalization.rs new file mode 100644 index 0000000000000..f1ce317b3f78b --- /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 Identity for T { + type Identity = Self; +} + +pub struct I8; + +impl 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 0000000000000..fb806bdb1e747 --- /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 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`.