File: static-recursive.stderr

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (25 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
warning: creating a shared reference to mutable static is discouraged
  --> $DIR/static-recursive.rs:3:36
   |
LL | static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 };
   |                                    ^^ 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 | static mut S: *const u8 = unsafe { &raw const S as *const *const u8 as *const u8 };
   |                                     +++++++++

warning: creating a shared reference to mutable static is discouraged
  --> $DIR/static-recursive.rs:19:20
   |
LL |         assert_eq!(S, *(S as *const *const u8));
   |                    ^ 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: 2 warnings emitted