about summary refs log tree commit diff
path: root/tests/ui/consts/assoc_const_generic_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/assoc_const_generic_impl.rs')
-rw-r--r--tests/ui/consts/assoc_const_generic_impl.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/ui/consts/assoc_const_generic_impl.rs b/tests/ui/consts/assoc_const_generic_impl.rs
new file mode 100644
index 00000000000..3475c862bfc
--- /dev/null
+++ b/tests/ui/consts/assoc_const_generic_impl.rs
@@ -0,0 +1,19 @@
+// build-fail
+
+trait ZeroSized: Sized {
+    const I_AM_ZERO_SIZED: ();
+    fn requires_zero_size(self);
+}
+
+impl<T: Sized> ZeroSized for T {
+    const I_AM_ZERO_SIZED: ()  = [()][std::mem::size_of::<Self>()]; //~ ERROR evaluation of `<u32 as ZeroSized>::I_AM_ZERO_SIZED` failed
+    fn requires_zero_size(self) {
+        let () = Self::I_AM_ZERO_SIZED;
+        println!("requires_zero_size called");
+    }
+}
+
+fn main() {
+    ().requires_zero_size();
+    42_u32.requires_zero_size();
+}