rust/tests/ui/lint/static-mut-refs.e2021.stderr

144 lines
7.4 KiB
Plaintext

warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:38:18
|
LL | let _y = &X;
| ^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
= note: `#[warn(static_mut_refs)]` on by default
help: use `&raw const` instead to create a raw pointer
|
LL | let _y = &raw const X;
| +++++++++
warning: creating a mutable reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:42:18
|
LL | let _y = &mut X;
| ^^^^^^ mutable reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
help: use `&raw mut` instead to create a raw pointer
|
LL | let _y = &raw mut X;
| +++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:50:22
|
LL | let ref _a = X;
| ^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:54:25
|
LL | let (_b, _c) = (&X, &Y);
| ^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
help: use `&raw const` instead to create a raw pointer
|
LL | let (_b, _c) = (&raw const X, &Y);
| +++++++++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:54:29
|
LL | let (_b, _c) = (&X, &Y);
| ^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
help: use `&raw const` instead to create a raw pointer
|
LL | let (_b, _c) = (&X, &raw const Y);
| +++++++++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:60:13
|
LL | foo(&X);
| ^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
help: use `&raw const` instead to create a raw pointer
|
LL | foo(&raw const X);
| +++++++++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:66:17
|
LL | let _ = Z.len();
| ^^^^^^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:72:33
|
LL | let _ = format!("{:?}", Z);
| ^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:76:18
|
LL | let _v = &A.value;
| ^^^^^^^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
help: use `&raw const` instead to create a raw pointer
|
LL | let _v = &raw const A.value;
| +++++++++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:80:18
|
LL | let _s = &A.s.value;
| ^^^^^^^^^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
help: use `&raw const` instead to create a raw pointer
|
LL | let _s = &raw const A.s.value;
| +++++++++
warning: creating a shared reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:84:22
|
LL | let ref _v = A.value;
| ^^^^^^^ shared reference to mutable static
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
warning: creating a mutable reference to mutable static is discouraged
--> $DIR/static-mut-refs.rs:14:14
|
LL | &mut ($x.0)
| ^^^^^^ mutable reference to mutable static
...
LL | let _x = bar!(FOO);
| --------- in this macro invocation
|
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html>
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
= note: this warning originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: 12 warnings emitted