diff options
| author | bors <bors@rust-lang.org> | 2023-09-07 00:24:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-07 00:24:45 +0000 |
| commit | 4e5b31c2b0023dba53a1b2827f4b7ac42aaaa18f (patch) | |
| tree | 628bbb11a517f98e33e45c1b19da882e077870ec /compiler/rustc_span/src | |
| parent | b0d45536acf8be99036c6a1261359e3cf89f9d63 (diff) | |
| parent | 89800a27fcbcd15641e06fb870b51c320a78668f (diff) | |
Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-usage, r=est31
Lint on invalid usage of `UnsafeCell::raw_get` in reference casting
This PR proposes to take into account `UnsafeCell::raw_get` method call for non-Freeze types for the `invalid_reference_casting` lint.
The goal of this is to catch those kind of invalid reference casting:
```rust
fn as_mut<T>(x: &T) -> &mut T {
unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
}
```
r? `@est31`
Diffstat (limited to 'compiler/rustc_span/src')
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 656deebb5d0..2bb58f94adc 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1639,6 +1639,7 @@ symbols! { unsafe_block_in_unsafe_fn, unsafe_cell, unsafe_cell_from_mut, + unsafe_cell_raw_get, unsafe_no_drop_flag, unsafe_pin_internals, unsize, |
