diff options
| author | Ralf Jung <post@ralfj.de> | 2024-08-17 14:49:35 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-08-17 14:49:35 +0200 |
| commit | 8b642a1883c489c74befca5b75514767a1f80314 (patch) | |
| tree | 7d4d1c9121210e9302089e6688bc49ffe3037647 /compiler/rustc_lint_defs/src/builtin.rs | |
| parent | 355a307a874077eff12bd99c6fd3eb6bfda79993 (diff) | |
| download | rust-8b642a1883c489c74befca5b75514767a1f80314.tar.gz rust-8b642a1883c489c74befca5b75514767a1f80314.zip | |
make writes_through_immutable_pointer a hard error
Diffstat (limited to 'compiler/rustc_lint_defs/src/builtin.rs')
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index c731b03a875..3c0181a5e6e 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -142,7 +142,6 @@ declare_lint_pass! { USELESS_DEPRECATED, WARNINGS, WASM_C_ABI, - WRITES_THROUGH_IMMUTABLE_POINTER, // tidy-alphabetical-end ] } @@ -4697,40 +4696,6 @@ declare_lint! { } declare_lint! { - /// The `writes_through_immutable_pointer` lint detects writes through pointers derived from - /// shared references. - /// - /// ### Example - /// - /// ```rust,compile_fail - /// #![feature(const_mut_refs)] - /// const WRITE_AFTER_CAST: () = unsafe { - /// let mut x = 0; - /// let ptr = &x as *const i32 as *mut i32; - /// *ptr = 0; - /// }; - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Shared references are immutable (when there is no `UnsafeCell` involved), - /// and writing through them or through pointers derived from them is Undefined Behavior. - /// The compiler recently learned to detect such Undefined Behavior during compile-time - /// evaluation, and in the future this will raise a hard error. - /// - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub WRITES_THROUGH_IMMUTABLE_POINTER, - Warn, - "shared references are immutable, and pointers derived from them must not be written to", - @future_incompatible = FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps, - reference: "issue #X <https://github.com/rust-lang/rust/issues/X>", - }; -} - -declare_lint! { /// The `private_macro_use` lint detects private macros that are imported /// with `#[macro_use]`. /// |
