From 42f99efa0bb0dc307ea2fabb02f7b15bce1a7e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A1=BB=E8=AF=AD?= Date: Sat, 31 May 2025 21:26:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D20-11=E7=9A=84mimr=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A3=80=E6=9F=A5=E5=8F=8D=E9=A6=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原数据可能是未安装nightly 版本的 Rust 和 Miri的结果,英文原版网页运行也是这个反馈。 --- .../ch20-advanced-features/listing-20-11/output.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/listings/ch20-advanced-features/listing-20-11/output.txt b/listings/ch20-advanced-features/listing-20-11/output.txt index bf64b38..6494426 100644 --- a/listings/ch20-advanced-features/listing-20-11/output.txt +++ b/listings/ch20-advanced-features/listing-20-11/output.txt @@ -1,5 +1,16 @@ $ cargo +nightly miri run Compiling unsafe-example v0.1.0 (file:///projects/unsafe-example) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s - Running `file:///home/.rustup/toolchains/nightly/bin/cargo-miri runner target/miri/debug/unsafe-example` + Running `/Users/chris/.rustup/toolchains/nightly-aarch64-apple-darwin/bin/cargo-miri runner target/miri/aarch64-apple-darwin/debug/unsafe-example` +warning: creating a shared reference to mutable static is discouraged + --> src/main.rs:14:33 + | +14 | println!("COUNTER: {}", COUNTER); + | ^^^^^^^ shared reference to mutable static + | + = note: for more information, see + = 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 + COUNTER: 3 +