Skip to content

Commit

Permalink
Auto merge of #115166 - Urgau:invalid_ref_casting-invalid-unsafecell-…
Browse files Browse the repository at this point in the history
…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`
  • Loading branch information
bors committed Sep 7, 2023
2 parents 4fe7510 + 42e88a1 commit 957ec97
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 957ec97

Please sign in to comment.