diff options
| author | bors <bors@rust-lang.org> | 2023-06-01 01:27:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-01 01:27:32 +0000 |
| commit | ba1690bedd6ada4e8d91bfecb3d0ccc2b6de85ba (patch) | |
| tree | 6e669dc7e3fd97892062894efef4a9b56e8edad1 /compiler/rustc_span/src | |
| parent | 9af3865deca9c601ef32ef4ed29f7cae5fed50a9 (diff) | |
| parent | 32d4e1c3c71fa30c83405eee7ff8b9bba6a903f0 (diff) | |
| download | rust-ba1690bedd6ada4e8d91bfecb3d0ccc2b6de85ba.tar.gz rust-ba1690bedd6ada4e8d91bfecb3d0ccc2b6de85ba.zip | |
Auto merge of #111567 - Urgau:uplift_cast_ref_to_mut, r=b-naber
Uplift `clippy::cast_ref_to_mut` lint
This PR aims at uplifting the `clippy::cast_ref_to_mut` lint into rustc.
## `cast_ref_to_mut`
(deny-by-default)
The `cast_ref_to_mut` lint checks for casts of `&T` to `&mut T` without using interior mutability.
### Example
```rust,compile_fail
fn x(r: &i32) {
unsafe {
*(r as *const i32 as *mut i32) += 1;
}
}
```
### Explanation
Casting `&T` to `&mut T` without interior mutability is undefined behavior, as it's a violation of Rust reference aliasing requirements.
-----
Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751
`@rustbot` label: +I-lang-nominated
r? compiler
-----
For Clippy:
changelog: Moves: Uplifted `clippy::cast_ref_to_mut` into rustc
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 1185563ea80..2f002e42427 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1146,6 +1146,8 @@ symbols! { profiler_builtins, profiler_runtime, ptr, + ptr_cast_mut, + ptr_from_ref, ptr_guaranteed_cmp, ptr_mask, ptr_null, |
