about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-08-30 09:31:21 +0200
committerRalf Jung <post@ralfj.de>2019-08-30 09:35:33 +0200
commite7fed140a4db638562077afc0ec5ef174a25bcc0 (patch)
treeaf1f9f5a8b9a4655a1c6a6bc223745d666941f79
parentcf574091fb10496a72b8f105d6f8f14f3eff0db6 (diff)
downloadrust-e7fed140a4db638562077afc0ec5ef174a25bcc0.tar.gz
rust-e7fed140a4db638562077afc0ec5ef174a25bcc0.zip
explain why REF_AS_USIZE is important
-rw-r--r--src/test/ui/consts/const-eval/ub-ref.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-eval/ub-ref.rs b/src/test/ui/consts/const-eval/ub-ref.rs
index bbab85c2121..03ac12c8b1a 100644
--- a/src/test/ui/consts/const-eval/ub-ref.rs
+++ b/src/test/ui/consts/const-eval/ub-ref.rs
@@ -11,6 +11,9 @@ const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
 const NULL: &u16 = unsafe { mem::transmute(0usize) };
 //~^ ERROR it is undefined behavior to use this value
 
+// It is very important that we reject this: We do promote `&(4 * REF_AS_USIZE)`,
+// but that would fail to compile; so we ended up breaking user code that would
+// have worked fine had we not promoted.
 const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
 //~^ ERROR it is undefined behavior to use this value