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