1
1
warning: attempting to modify a `const` item
2
- --> $DIR/lint-const-item-mutation.rs:17 :5
2
+ --> $DIR/lint-const-item-mutation.rs:34 :5
3
3
|
4
4
LL | ARRAY[0] = 5;
5
5
| ^^^^^^^^^^^^
6
6
|
7
7
= note: `#[warn(const_item_mutation)]` on by default
8
8
= note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified
9
9
note: `const` item defined here
10
- --> $DIR/lint-const-item-mutation.rs:12 :1
10
+ --> $DIR/lint-const-item-mutation.rs:26 :1
11
11
|
12
12
LL | const ARRAY: [u8; 1] = [25];
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
14
15
15
warning: attempting to modify a `const` item
16
- --> $DIR/lint-const-item-mutation.rs:18 :5
16
+ --> $DIR/lint-const-item-mutation.rs:35 :5
17
17
|
18
18
LL | MY_STRUCT.field = false;
19
19
| ^^^^^^^^^^^^^^^^^^^^^^^
20
20
|
21
21
= note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified
22
22
note: `const` item defined here
23
- --> $DIR/lint-const-item-mutation.rs:13 :1
23
+ --> $DIR/lint-const-item-mutation.rs:27 :1
24
24
|
25
25
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
26
26
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27
27
28
28
warning: attempting to modify a `const` item
29
- --> $DIR/lint-const-item-mutation.rs:19 :5
29
+ --> $DIR/lint-const-item-mutation.rs:36 :5
30
30
|
31
31
LL | MY_STRUCT.inner_array[0] = 'b';
32
32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33
33
|
34
34
= note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified
35
35
note: `const` item defined here
36
- --> $DIR/lint-const-item-mutation.rs:13 :1
36
+ --> $DIR/lint-const-item-mutation.rs:27 :1
37
37
|
38
38
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
39
39
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40
40
41
41
warning: taking a mutable reference to a `const` item
42
- --> $DIR/lint-const-item-mutation.rs:20 :5
42
+ --> $DIR/lint-const-item-mutation.rs:37 :5
43
43
|
44
44
LL | MY_STRUCT.use_mut();
45
45
| ^^^^^^^^^^^^^^^^^^^
@@ -52,38 +52,76 @@ note: mutable reference created due to call to this method
52
52
LL | fn use_mut(&mut self) {}
53
53
| ^^^^^^^^^^^^^^^^^^^^^
54
54
note: `const` item defined here
55
- --> $DIR/lint-const-item-mutation.rs:13 :1
55
+ --> $DIR/lint-const-item-mutation.rs:27 :1
56
56
|
57
57
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
58
58
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
59
59
60
60
warning: taking a mutable reference to a `const` item
61
- --> $DIR/lint-const-item-mutation.rs:21 :5
61
+ --> $DIR/lint-const-item-mutation.rs:38 :5
62
62
|
63
63
LL | &mut MY_STRUCT;
64
64
| ^^^^^^^^^^^^^^
65
65
|
66
66
= note: each usage of a `const` item creates a new temporary
67
67
= note: the mutable reference will refer to this temporary, not the original `const` item
68
68
note: `const` item defined here
69
- --> $DIR/lint-const-item-mutation.rs:13 :1
69
+ --> $DIR/lint-const-item-mutation.rs:27 :1
70
70
|
71
71
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
72
72
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
73
74
74
warning: taking a mutable reference to a `const` item
75
- --> $DIR/lint-const-item-mutation.rs:22 :5
75
+ --> $DIR/lint-const-item-mutation.rs:39 :5
76
76
|
77
77
LL | (&mut MY_STRUCT).use_mut();
78
78
| ^^^^^^^^^^^^^^^^
79
79
|
80
80
= note: each usage of a `const` item creates a new temporary
81
81
= note: the mutable reference will refer to this temporary, not the original `const` item
82
82
note: `const` item defined here
83
- --> $DIR/lint-const-item-mutation.rs:13 :1
83
+ --> $DIR/lint-const-item-mutation.rs:27 :1
84
84
|
85
85
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
86
86
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
87
87
88
- warning: 6 warnings emitted
88
+ warning: attempting to modify a `const` item
89
+ --> $DIR/lint-const-item-mutation.rs:51:5
90
+ |
91
+ LL | MUTABLE2.msg = "wow";
92
+ | ^^^^^^^^^^^^^^^^^^^^
93
+ |
94
+ = note: each usage of a `const` item creates a new temporary - the original `const` item will not be modified
95
+ note: `const` item defined here
96
+ --> $DIR/lint-const-item-mutation.rs:30:1
97
+ |
98
+ LL | const MUTABLE2: Mutable2 = Mutable2 { msg: "", other: String::new() };
99
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
100
+
101
+ warning: taking a mutable reference to a `const` item
102
+ --> $DIR/lint-const-item-mutation.rs:52:5
103
+ |
104
+ LL | VEC.push(0);
105
+ | ^^^^^^^^^^^
106
+ |
107
+ = note: each usage of a `const` item creates a new temporary
108
+ = note: the mutable reference will refer to this temporary, not the original `const` item
109
+ note: mutable reference created due to call to this method
110
+ --> $SRC_DIR/alloc/src/vec.rs:LL:COL
111
+ |
112
+ LL | / pub fn push(&mut self, value: T) {
113
+ LL | | // This will panic or abort if we would allocate > isize::MAX bytes
114
+ LL | | // or if the length increment would overflow for zero-sized types.
115
+ LL | | if self.len == self.buf.capacity() {
116
+ ... |
117
+ LL | | }
118
+ LL | | }
119
+ | |_____^
120
+ note: `const` item defined here
121
+ --> $DIR/lint-const-item-mutation.rs:31:1
122
+ |
123
+ LL | const VEC: Vec<i32> = Vec::new();
124
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125
+
126
+ warning: 8 warnings emitted
89
127
0 commit comments