1
Fork 0

Don't emit null pointer lint for raw ref of null deref

This commit is contained in:
Michael Goulet 2024-08-18 12:33:21 -04:00
parent f2a80a0f89
commit 367183bc0c
7 changed files with 28 additions and 41 deletions

View file

@ -509,8 +509,6 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
}
ExprKind::RawBorrow { arg, .. } => {
if let ExprKind::Scope { value: arg, .. } = self.thir[arg].kind
// THIR desugars UNSAFE_STATIC into *UNSAFE_STATIC_REF, where
// UNSAFE_STATIC_REF holds the addr of the UNSAFE_STATIC, so: take two steps
&& let ExprKind::Deref { arg } = self.thir[arg].kind
{
// Taking a raw ref to a deref place expr is always safe.