Disallow hidden references to mutable static
This commit is contained in:
parent
d0985bb524
commit
74cab947f7
13 changed files with 203 additions and 133 deletions
|
@ -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!
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue