From 74cab947f79045e34eb973199274ee5f3c132bd8 Mon Sep 17 00:00:00 2001 From: Obei Sideg Date: Sat, 24 Aug 2024 06:47:43 +0300 Subject: Disallow hidden references to mutable static --- compiler/rustc_error_codes/src/error_codes/E0796.md | 6 +++--- compiler/rustc_error_codes/src/lib.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'compiler/rustc_error_codes/src') diff --git a/compiler/rustc_error_codes/src/error_codes/E0796.md b/compiler/rustc_error_codes/src/error_codes/E0796.md index 7ac429e5215..ced163e98f7 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0796.md +++ b/compiler/rustc_error_codes/src/error_codes/E0796.md @@ -1,14 +1,14 @@ +#### Note: this error code is no longer emitted by the compiler. + You have created a reference to a mutable static. Erroneous code example: -```compile_fail,edition2024,E0796 +``` static mut X: i32 = 23; - fn work() { let _val = unsafe { X }; } - let x_ref = unsafe { &mut X }; work(); // The next line has Undefined Behavior! diff --git a/compiler/rustc_error_codes/src/lib.rs b/compiler/rustc_error_codes/src/lib.rs index 150f99a3ee7..6c887e31924 100644 --- a/compiler/rustc_error_codes/src/lib.rs +++ b/compiler/rustc_error_codes/src/lib.rs @@ -679,3 +679,4 @@ E0798: 0798, // E0723, // unstable feature in `const` context // E0738, // Removed; errored on `#[track_caller] fn`s in `extern "Rust" { ... }`. // E0744, // merged into E0728 +// E0796, // unused error code. We use `static_mut_refs` lint instead. -- cgit 1.4.1-3-g733a5