2024-02-17 22:01:56 +03:00
warning: creating a mutable reference to mutable static is discouraged
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:18:23
|
LL | let _y2 = &mut static_x_mut;
2024-02-17 22:01:56 +03:00
| ^^^^^^^^^^^^^^^^^ mutable reference to mutable static
2023-12-22 15:12:01 +03:00
|
= note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447>
2024-02-17 22:01:56 +03:00
= note: this will be a hard error in the 2024 edition
= note: this mutable reference has lifetime `'static`, but if the static gets accessed (read or written) by any other means, or any other reference is created, then any further use of this mutable reference is Undefined Behavior
= note: `#[warn(static_mut_refs)]` on by default
help: use `addr_of_mut!` instead to create a raw pointer
2023-12-22 15:12:01 +03:00
|
LL | let _y2 = addr_of_mut!(static_x_mut);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-08-08 14:28:26 +02:00
error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:10:19
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y1 = &mut x;
2018-08-08 14:28:26 +02:00
| ^^^^^^ cannot borrow as mutable
2023-01-01 00:06:31 -08:00
|
help: consider changing this to be mutable
|
LL | let mut x = 1;
| +++
2018-08-08 14:28:26 +02:00
error[E0596]: cannot borrow immutable static item `static_x` as mutable
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:16:19
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y1 = &mut static_x;
2018-08-08 14:28:26 +02:00
| ^^^^^^^^^^^^^ cannot borrow as mutable
error[E0596]: cannot borrow `*box_x` as mutable, as `box_x` is not declared as mutable
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:28:19
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y1 = &mut *box_x;
2018-08-08 14:28:26 +02:00
| ^^^^^^^^^^^ cannot borrow as mutable
2023-01-01 00:06:31 -08:00
|
help: consider changing this to be mutable
|
LL | let mut box_x = Box::new(1);
| +++
2018-08-08 14:28:26 +02:00
error[E0596]: cannot borrow `*ref_x` as mutable, as it is behind a `&` reference
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:37:19
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y1 = &mut *ref_x;
2018-08-08 14:28:26 +02:00
| ^^^^^^^^^^^ `ref_x` is a `&` reference, so the data it refers to cannot be borrowed as mutable
2022-12-28 21:52:57 -08:00
|
help: consider changing this to be a mutable reference
|
LL | let ref_x = &mut x;
2023-04-19 18:22:03 +12:00
| +++
2018-08-08 14:28:26 +02:00
error[E0596]: cannot borrow `*ptr_x` as mutable, as it is behind a `*const` pointer
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:47:23
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y1 = &mut *ptr_x;
2018-08-08 14:28:26 +02:00
| ^^^^^^^^^^^ `ptr_x` is a `*const` pointer, so the data it refers to cannot be borrowed as mutable
2022-12-28 21:52:57 -08:00
|
help: consider changing this to be a mutable pointer
|
2023-12-22 15:12:01 +03:00
LL | let ptr_x: *const _ = &mut x;
| +++
2018-08-08 14:28:26 +02:00
error[E0596]: cannot borrow `*foo_ref.f` as mutable, as it is behind a `&` reference
2023-12-22 15:12:01 +03:00
--> $DIR/borrowck-access-permissions.rs:60:18
2018-08-08 14:28:26 +02:00
|
2019-03-17 10:52:07 +01:00
LL | let _y = &mut *foo_ref.f;
2018-08-08 14:28:26 +02:00
| ^^^^^^^^^^^^^^^ `foo_ref` is a `&` reference, so the data it refers to cannot be borrowed as mutable
2022-12-28 21:52:57 -08:00
|
help: consider changing this to be a mutable reference
|
LL | let foo_ref = &mut foo;
2023-04-19 18:22:03 +12:00
| +++
2018-08-08 14:28:26 +02:00
2023-12-22 15:12:01 +03:00
error: aborting due to 6 previous errors; 1 warning emitted
2018-08-08 14:28:26 +02:00
For more information about this error, try `rustc --explain E0596`.