@@ -31,8 +31,19 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) };
3131               HEX_DUMP
3232           }
3333
34+ error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory
35+   --> $DIR/mut_ref_in_final.rs:29:1
36+    |
37+ LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) };
38+    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value
39+    |
40+    = 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.
41+    = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
42+                HEX_DUMP
43+            }
44+ 
3445error[E0716]: temporary value dropped while borrowed
35-   --> $DIR/mut_ref_in_final.rs:50 :65
46+   --> $DIR/mut_ref_in_final.rs:52 :65
3647   |
3748LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
3849   |                                  -------------------------------^^--
@@ -42,7 +53,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
4253   |                                  using this value as a constant requires that borrow lasts for `'static`
4354
4455error[E0716]: temporary value dropped while borrowed
45-   --> $DIR/mut_ref_in_final.rs:53 :67
56+   --> $DIR/mut_ref_in_final.rs:55 :67
4657   |
4758LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
4859   |                                    -------------------------------^^--
@@ -52,7 +63,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
5263   |                                    using this value as a static requires that borrow lasts for `'static`
5364
5465error[E0716]: temporary value dropped while borrowed
55-   --> $DIR/mut_ref_in_final.rs:56 :71
66+   --> $DIR/mut_ref_in_final.rs:58 :71
5667   |
5768LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
5869   |                                        -------------------------------^^--
@@ -62,30 +73,30 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
6273   |                                        using this value as a static requires that borrow lasts for `'static`
6374
6475error[E0764]: mutable references are not allowed in the final value of statics
65-   --> $DIR/mut_ref_in_final.rs:69 :53
76+   --> $DIR/mut_ref_in_final.rs:71 :53
6677   |
6778LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
6879   |                                                     ^^^^^^^
6980
7081error[E0764]: mutable references are not allowed in the final value of statics
71-   --> $DIR/mut_ref_in_final.rs:71 :54
82+   --> $DIR/mut_ref_in_final.rs:73 :54
7283   |
7384LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
7485   |                                                      ^^^^^^
7586
7687error[E0764]: mutable references are not allowed in the final value of constants
77-   --> $DIR/mut_ref_in_final.rs:73 :52
88+   --> $DIR/mut_ref_in_final.rs:75 :52
7889   |
7990LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
8091   |                                                    ^^^^^^^
8192
8293error[E0764]: mutable references are not allowed in the final value of constants
83-   --> $DIR/mut_ref_in_final.rs:75 :53
94+   --> $DIR/mut_ref_in_final.rs:77 :53
8495   |
8596LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
8697   |                                                     ^^^^^^
8798
88- error: aborting due to 11  previous errors
99+ error: aborting due to 12  previous errors
89100
90101Some errors have detailed explanations: E0080, E0716, E0764.
91102For more information about an error, try `rustc --explain E0080`.
0 commit comments