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:39: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:43: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:51: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:55: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:55: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:61: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:67: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:73: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:77: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:81: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:85: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:15: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