@@ -35,8 +35,19 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) };
3535 HEX_DUMP
3636 }
3737
38+ error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory
39+ --> $DIR/mut_ref_in_final.rs:29:1
40+ |
41+ LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) };
42+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
43+ |
44+ = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
45+ = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
46+ HEX_DUMP
47+ }
48+
3849error[E0716]: temporary value dropped while borrowed
39- --> $DIR/mut_ref_in_final.rs:50 :65
50+ --> $DIR/mut_ref_in_final.rs:52 :65
4051 |
4152LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
4253 | -------------------------------^^--
@@ -46,7 +57,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
4657 | using this value as a constant requires that borrow lasts for `'static`
4758
4859error[E0716]: temporary value dropped while borrowed
49- --> $DIR/mut_ref_in_final.rs:53 :67
60+ --> $DIR/mut_ref_in_final.rs:55 :67
5061 |
5162LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
5263 | -------------------------------^^--
@@ -56,7 +67,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
5667 | using this value as a static requires that borrow lasts for `'static`
5768
5869error[E0716]: temporary value dropped while borrowed
59- --> $DIR/mut_ref_in_final.rs:56 :71
70+ --> $DIR/mut_ref_in_final.rs:58 :71
6071 |
6172LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
6273 | -------------------------------^^--
@@ -66,30 +77,30 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
6677 | using this value as a static requires that borrow lasts for `'static`
6778
6879error[E0764]: mutable references are not allowed in the final value of statics
69- --> $DIR/mut_ref_in_final.rs:69 :53
80+ --> $DIR/mut_ref_in_final.rs:71 :53
7081 |
7182LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
7283 | ^^^^^^^
7384
7485error[E0764]: mutable references are not allowed in the final value of statics
75- --> $DIR/mut_ref_in_final.rs:71 :54
86+ --> $DIR/mut_ref_in_final.rs:73 :54
7687 |
7788LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
7889 | ^^^^^^
7990
8091error[E0764]: mutable references are not allowed in the final value of constants
81- --> $DIR/mut_ref_in_final.rs:73 :52
92+ --> $DIR/mut_ref_in_final.rs:75 :52
8293 |
8394LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
8495 | ^^^^^^^
8596
8697error[E0764]: mutable references are not allowed in the final value of constants
87- --> $DIR/mut_ref_in_final.rs:75 :53
98+ --> $DIR/mut_ref_in_final.rs:77 :53
8899 |
89100LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
90101 | ^^^^^^
91102
92- error: aborting due to 11 previous errors
103+ error: aborting due to 12 previous errors
93104
94105Some errors have detailed explanations: E0080, E0716, E0764.
95106For more information about an error, try `rustc --explain E0080`.
0 commit comments