1
1
warning: attempting to modify a `const` item
2
- --> $DIR/lint-const-item-mutation.rs:27 :5
2
+ --> $DIR/lint-const-item-mutation.rs:33 :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:21 :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:28 :5
16
+ --> $DIR/lint-const-item-mutation.rs:34 :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:22 :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:29 :5
29
+ --> $DIR/lint-const-item-mutation.rs:35 :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:22 :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:30 :5
42
+ --> $DIR/lint-const-item-mutation.rs:36 :5
43
43
|
44
44
LL | MY_STRUCT.use_mut();
45
45
| ^^^^^^^^^^^^^^^^^^^
@@ -52,38 +52,51 @@ 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:22 :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:31 :5
61
+ --> $DIR/lint-const-item-mutation.rs:37 :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:22 :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:32 :5
75
+ --> $DIR/lint-const-item-mutation.rs:38 :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:22 :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:50: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: 7 warnings emitted
89
102
0 commit comments