diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-01-09 13:23:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-09 13:23:15 +0100 |
| commit | 4a24b5bc054f78c165cbdf4dd3e0a7f56f468d7d (patch) | |
| tree | 8c1fef00c6ab1567f6552704e4593932d04d6685 /compiler/rustc_error_codes/src | |
| parent | be00c5a9b89161b7f45ba80340f709e8e41122f9 (diff) | |
| parent | a8aa6878f63e53a9b0cfee542e9765407e1ca0d6 (diff) | |
| download | rust-4a24b5bc054f78c165cbdf4dd3e0a7f56f468d7d.tar.gz rust-4a24b5bc054f78c165cbdf4dd3e0a7f56f468d7d.zip | |
Rollup merge of #117556 - obeis:static-mut-ref-lint, r=davidtwco
Disallow reference to `static mut` and adding `static_mut_ref` lint Closes #114447 r? `@scottmcm`
Diffstat (limited to 'compiler/rustc_error_codes/src')
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_error_codes/src/error_codes/E0796.md | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 1028d43f9c5..a1391cceb71 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -515,6 +515,7 @@ E0792: include_str!("./error_codes/E0792.md"), E0793: include_str!("./error_codes/E0793.md"), E0794: include_str!("./error_codes/E0794.md"), E0795: include_str!("./error_codes/E0795.md"), +E0796: include_str!("./error_codes/E0796.md"), } // Undocumented removed error codes. Note that many removed error codes are kept in the list above diff --git a/compiler/rustc_error_codes/src/error_codes/E0796.md b/compiler/rustc_error_codes/src/error_codes/E0796.md new file mode 100644 index 00000000000..cea18f8db85 --- /dev/null +++ b/compiler/rustc_error_codes/src/error_codes/E0796.md @@ -0,0 +1,22 @@ +Reference of mutable static. + +Erroneous code example: + +```compile_fail,edition2024,E0796 +static mut X: i32 = 23; +static mut Y: i32 = 24; + +unsafe { + let y = &X; + let ref x = X; + let (x, y) = (&X, &Y); + foo(&X); +} + +fn foo<'a>(_x: &'a i32) {} +``` + +Mutable statics can be written to by multiple threads: aliasing violations or +data races will cause undefined behavior. + +Reference of mutable static is a hard error from 2024 edition. |
