@@ -35,8 +35,19 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) };
35
35
HEX_DUMP
36
36
}
37
37
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
+
38
49
error[E0716]: temporary value dropped while borrowed
39
- --> $DIR/mut_ref_in_final.rs:50 :65
50
+ --> $DIR/mut_ref_in_final.rs:52 :65
40
51
|
41
52
LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
42
53
| -------------------------------^^--
@@ -46,7 +57,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
46
57
| using this value as a constant requires that borrow lasts for `'static`
47
58
48
59
error[E0716]: temporary value dropped while borrowed
49
- --> $DIR/mut_ref_in_final.rs:53 :67
60
+ --> $DIR/mut_ref_in_final.rs:55 :67
50
61
|
51
62
LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
52
63
| -------------------------------^^--
@@ -56,7 +67,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
56
67
| using this value as a static requires that borrow lasts for `'static`
57
68
58
69
error[E0716]: temporary value dropped while borrowed
59
- --> $DIR/mut_ref_in_final.rs:56 :71
70
+ --> $DIR/mut_ref_in_final.rs:58 :71
60
71
|
61
72
LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
62
73
| -------------------------------^^--
@@ -66,30 +77,30 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
66
77
| using this value as a static requires that borrow lasts for `'static`
67
78
68
79
error[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
70
81
|
71
82
LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
72
83
| ^^^^^^^
73
84
74
85
error[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
76
87
|
77
88
LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
78
89
| ^^^^^^
79
90
80
91
error[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
82
93
|
83
94
LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
84
95
| ^^^^^^^
85
96
86
97
error[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
88
99
|
89
100
LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
90
101
| ^^^^^^
91
102
92
- error: aborting due to 11 previous errors
103
+ error: aborting due to 12 previous errors
93
104
94
105
Some errors have detailed explanations: E0080, E0716, E0764.
95
106
For more information about an error, try `rustc --explain E0080`.
0 commit comments