2020-08-10 06:16:30 -05:00
|
|
|
warning: attempting to modify a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:37:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | ARRAY[0] = 5;
|
|
|
|
| ^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-07 19:39:35 -06:00
|
|
|
= note: each usage of a `const` item creates a new temporary; the original `const` item will not be modified
|
2020-08-10 06:16:30 -05:00
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:26:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | const ARRAY: [u8; 1] = [25];
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
2022-09-18 10:55:36 -05:00
|
|
|
= note: `#[warn(const_item_mutation)]` on by default
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
warning: attempting to modify a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:38:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | MY_STRUCT.field = false;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-07 19:39:35 -06:00
|
|
|
= note: each usage of a `const` item creates a new temporary; the original `const` item will not be modified
|
2020-08-10 06:16:30 -05:00
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:27:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
2020-09-28 22:51:57 -05:00
|
|
|
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
warning: attempting to modify a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:39:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | MY_STRUCT.inner_array[0] = 'b';
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-07 19:39:35 -06:00
|
|
|
= note: each usage of a `const` item creates a new temporary; the original `const` item will not be modified
|
2020-08-10 06:16:30 -05:00
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:27:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
2020-09-28 22:51:57 -05:00
|
|
|
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
warning: taking a mutable reference to a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:40:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | MY_STRUCT.use_mut();
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each usage of a `const` item creates a new temporary
|
|
|
|
= note: the mutable reference will refer to this temporary, not the original `const` item
|
|
|
|
note: mutable reference created due to call to this method
|
2020-09-28 22:51:57 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:9:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | fn use_mut(&mut self) {}
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:27:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
2020-09-28 22:51:57 -05:00
|
|
|
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
warning: taking a mutable reference to a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:41:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | &mut MY_STRUCT;
|
|
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each usage of a `const` item creates a new temporary
|
|
|
|
= note: the mutable reference will refer to this temporary, not the original `const` item
|
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:27:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
2020-09-28 22:51:57 -05:00
|
|
|
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
warning: taking a mutable reference to a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:42:5
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
|
|
|
LL | (&mut MY_STRUCT).use_mut();
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each usage of a `const` item creates a new temporary
|
|
|
|
= note: the mutable reference will refer to this temporary, not the original `const` item
|
|
|
|
note: `const` item defined here
|
2020-09-26 23:19:46 -05:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:27:1
|
2020-08-10 06:16:30 -05:00
|
|
|
|
|
2020-09-28 22:51:57 -05:00
|
|
|
LL | const MY_STRUCT: MyStruct = MyStruct { field: true, inner_array: ['a'], raw_ptr: 2 as *mut u8 };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-08-10 06:16:30 -05:00
|
|
|
|
2020-09-26 23:19:46 -05:00
|
|
|
warning: attempting to modify a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:54:5
|
2020-09-26 23:19:46 -05:00
|
|
|
|
|
|
|
|
LL | MUTABLE2.msg = "wow";
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
2020-11-07 19:39:35 -06:00
|
|
|
= note: each usage of a `const` item creates a new temporary; the original `const` item will not be modified
|
2020-09-26 23:19:46 -05:00
|
|
|
note: `const` item defined here
|
|
|
|
--> $DIR/lint-const-item-mutation.rs:30:1
|
|
|
|
|
|
|
|
|
LL | const MUTABLE2: Mutable2 = Mutable2 { msg: "", other: String::new() };
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
2020-09-26 23:19:46 -05:00
|
|
|
|
2020-10-01 00:16:32 -05:00
|
|
|
warning: taking a mutable reference to a `const` item
|
2020-12-17 14:25:55 -06:00
|
|
|
--> $DIR/lint-const-item-mutation.rs:55:5
|
2020-10-01 00:16:32 -05:00
|
|
|
|
|
|
|
|
LL | VEC.push(0);
|
|
|
|
| ^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
= note: each usage of a `const` item creates a new temporary
|
|
|
|
= note: the mutable reference will refer to this temporary, not the original `const` item
|
|
|
|
note: mutable reference created due to call to this method
|
2020-12-05 08:21:50 -06:00
|
|
|
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
2020-10-01 00:16:32 -05:00
|
|
|
note: `const` item defined here
|
|
|
|
--> $DIR/lint-const-item-mutation.rs:31:1
|
|
|
|
|
|
|
|
|
LL | const VEC: Vec<i32> = Vec::new();
|
2022-02-13 09:27:59 -06:00
|
|
|
| ^^^^^^^^^^^^^^^^^^^
|
2020-10-01 00:16:32 -05:00
|
|
|
|
|
|
|
warning: 8 warnings emitted
|
2020-08-10 06:16:30 -05:00
|
|
|
|