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_middle/src/error.rs | |
| 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_middle/src/error.rs')
0 files changed, 0 insertions, 0 deletions
