1
1
error[E0764]: mutable references are not allowed in the final value of constants
2
- --> $DIR/mut_ref_in_final.rs:9 :21
2
+ --> $DIR/mut_ref_in_final.rs:14 :21
3
3
|
4
4
LL | const B: *mut i32 = &mut 4;
5
5
| ^^^^^^
6
6
7
7
error[E0716]: temporary value dropped while borrowed
8
- --> $DIR/mut_ref_in_final.rs:15 :40
8
+ --> $DIR/mut_ref_in_final.rs:20 :40
9
9
|
10
10
LL | const B3: Option<&mut i32> = Some(&mut 42);
11
11
| ----------^^-
@@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42);
15
15
| using this value as a constant requires that borrow lasts for `'static`
16
16
17
17
error[E0716]: temporary value dropped while borrowed
18
- --> $DIR/mut_ref_in_final.rs:18 :42
18
+ --> $DIR/mut_ref_in_final.rs:23 :42
19
19
|
20
20
LL | const B4: Option<&mut i32> = helper(&mut 42);
21
21
| ------------^^-
@@ -24,8 +24,19 @@ LL | const B4: Option<&mut i32> = helper(&mut 42);
24
24
| | creates a temporary value which is freed while still in use
25
25
| using this value as a constant requires that borrow lasts for `'static`
26
26
27
+ error[E0080]: it is undefined behavior to use this value
28
+ --> $DIR/mut_ref_in_final.rs:26:1
29
+ |
30
+ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) };
31
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory
32
+ |
33
+ = 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.
34
+ = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
35
+ HEX_DUMP
36
+ }
37
+
27
38
error[E0716]: temporary value dropped while borrowed
28
- --> $DIR/mut_ref_in_final.rs:40 :65
39
+ --> $DIR/mut_ref_in_final.rs:50 :65
29
40
|
30
41
LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
31
42
| -------------------------------^^--
@@ -35,7 +46,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
35
46
| using this value as a constant requires that borrow lasts for `'static`
36
47
37
48
error[E0716]: temporary value dropped while borrowed
38
- --> $DIR/mut_ref_in_final.rs:43 :67
49
+ --> $DIR/mut_ref_in_final.rs:53 :67
39
50
|
40
51
LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
41
52
| -------------------------------^^--
@@ -45,7 +56,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
45
56
| using this value as a static requires that borrow lasts for `'static`
46
57
47
58
error[E0716]: temporary value dropped while borrowed
48
- --> $DIR/mut_ref_in_final.rs:46 :71
59
+ --> $DIR/mut_ref_in_final.rs:56 :71
49
60
|
50
61
LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
51
62
| -------------------------------^^--
@@ -55,30 +66,30 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
55
66
| using this value as a static requires that borrow lasts for `'static`
56
67
57
68
error[E0764]: mutable references are not allowed in the final value of statics
58
- --> $DIR/mut_ref_in_final.rs:59 :53
69
+ --> $DIR/mut_ref_in_final.rs:69 :53
59
70
|
60
71
LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
61
72
| ^^^^^^^
62
73
63
74
error[E0764]: mutable references are not allowed in the final value of statics
64
- --> $DIR/mut_ref_in_final.rs:61 :54
75
+ --> $DIR/mut_ref_in_final.rs:71 :54
65
76
|
66
77
LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
67
78
| ^^^^^^
68
79
69
80
error[E0764]: mutable references are not allowed in the final value of constants
70
- --> $DIR/mut_ref_in_final.rs:63 :52
81
+ --> $DIR/mut_ref_in_final.rs:73 :52
71
82
|
72
83
LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
73
84
| ^^^^^^^
74
85
75
86
error[E0764]: mutable references are not allowed in the final value of constants
76
- --> $DIR/mut_ref_in_final.rs:65 :53
87
+ --> $DIR/mut_ref_in_final.rs:75 :53
77
88
|
78
89
LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
79
90
| ^^^^^^
80
91
81
- error: aborting due to 10 previous errors
92
+ error: aborting due to 11 previous errors
82
93
83
- Some errors have detailed explanations: E0716, E0764.
84
- For more information about an error, try `rustc --explain E0716 `.
94
+ Some errors have detailed explanations: E0080, E0716, E0764.
95
+ For more information about an error, try `rustc --explain E0080 `.
0 commit comments