summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/assoc_const_generic_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/assoc_const_generic_impl.rs')
-rw-r--r--src/test/ui/consts/assoc_const_generic_impl.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/ui/consts/assoc_const_generic_impl.rs b/src/test/ui/consts/assoc_const_generic_impl.rs
new file mode 100644
index 000000000..71d947b0c
--- /dev/null
+++ b/src/test/ui/consts/assoc_const_generic_impl.rs
@@ -0,0 +1,22 @@
+// build-fail
+
+#![warn(const_err)]
+
+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>()]; //~ WARN any use of this value
+ //~| WARN this was previously accepted by the compiler but is being phased out
+ fn requires_zero_size(self) {
+ let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered
+ println!("requires_zero_size called");
+ }
+}
+
+fn main() {
+ ().requires_zero_size();
+ 42_u32.requires_zero_size();
+}