|
1 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a constant are not allowed |
| 1 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
2 | 2 | --> $DIR/mut_ref_in_final.rs:15:21
|
3 | 3 | |
|
4 | 4 | LL | const B: *mut i32 = &mut 4;
|
5 |
| - | ^^^^^^ |
| 5 | + | ^^^^^^ this mutable borrow refers to such a temporary |
| 6 | + | |
| 7 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 8 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 9 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
6 | 10 |
|
7 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a constant are not allowed |
| 11 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
8 | 12 | --> $DIR/mut_ref_in_final.rs:21:35
|
9 | 13 | |
|
10 | 14 | LL | const B3: Option<&mut i32> = Some(&mut 42);
|
11 |
| - | ^^^^^^^ |
| 15 | + | ^^^^^^^ this mutable borrow refers to such a temporary |
| 16 | + | |
| 17 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 18 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 19 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
12 | 20 |
|
13 | 21 | error[E0716]: temporary value dropped while borrowed
|
14 | 22 | --> $DIR/mut_ref_in_final.rs:24:42
|
@@ -72,29 +80,45 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42));
|
72 | 80 | | | creates a temporary value which is freed while still in use
|
73 | 81 | | using this value as a static requires that borrow lasts for `'static`
|
74 | 82 |
|
75 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a static are not allowed |
| 83 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
76 | 84 | --> $DIR/mut_ref_in_final.rs:71:53
|
77 | 85 | |
|
78 | 86 | LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
79 |
| - | ^^^^^^^ |
| 87 | + | ^^^^^^^ this mutable borrow refers to such a temporary |
| 88 | + | |
| 89 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 90 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 91 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
80 | 92 |
|
81 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a static are not allowed |
| 93 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
82 | 94 | --> $DIR/mut_ref_in_final.rs:73:54
|
83 | 95 | |
|
84 | 96 | LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
85 |
| - | ^^^^^^ |
| 97 | + | ^^^^^^ this mutable borrow refers to such a temporary |
| 98 | + | |
| 99 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 100 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 101 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
86 | 102 |
|
87 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a constant are not allowed |
| 103 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
88 | 104 | --> $DIR/mut_ref_in_final.rs:75:52
|
89 | 105 | |
|
90 | 106 | LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
|
91 |
| - | ^^^^^^^ |
| 107 | + | ^^^^^^^ this mutable borrow refers to such a temporary |
| 108 | + | |
| 109 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 110 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 111 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
92 | 112 |
|
93 |
| -error[E0764]: mutable borrows of lifetime-extended temporaries in the top-level scope of a constant are not allowed |
| 113 | +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed |
94 | 114 | --> $DIR/mut_ref_in_final.rs:77:53
|
95 | 115 | |
|
96 | 116 | LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 };
|
97 |
| - | ^^^^^^ |
| 117 | + | ^^^^^^ this mutable borrow refers to such a temporary |
| 118 | + | |
| 119 | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program |
| 120 | + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable |
| 121 | + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` |
98 | 122 |
|
99 | 123 | error: aborting due to 12 previous errors
|
100 | 124 |
|
|
0 commit comments