rust/compiler/rustc_mir_build/src
Matthias Krüger 93bf791e8b
Rollup merge of #129248 - compiler-errors:raw-ref-deref, r=nnethercote
Taking a raw ref (`&raw (const|mut)`) of a deref of pointer (`*ptr`) is always safe

T-opsem decided in https://github.com/rust-lang/reference/pull/1387 that `*ptr` is only unsafe if the place is accessed. This means that taking a raw ref of a deref expr is always safe, since it doesn't constitute a read.

This also relaxes the `DEREF_NULLPTR` lint to stop warning in the case of raw ref of a deref'd nullptr, and updates its docs to reflect that change in the UB specification.

This does not change the behavior of `addr_of!((*ptr).field)`, since field projections still require the projection is in-bounds.

I'm on the fence whether this requires an FCP, since it's something that is guaranteed by the reference you could ostensibly call this a bugfix since we were counting truly safe operations as unsafe. Perhaps someone on opsem has a strong opinion? cc `@rust-lang/opsem`
2024-10-24 10:35:39 +02:00
..
build Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxu 2024-10-23 22:11:05 +02:00
thir Rollup merge of #131909 - clubby789:enum-overflow-cast, r=compiler-errors 2024-10-24 14:19:56 +11:00
check_unsafety.rs Don't emit null pointer lint for raw ref of null deref 2024-10-06 22:36:51 -04:00
errors.rs Rollup merge of #131381 - Nadrieril:min-match-ergonomics, r=pnkfelix 2024-10-16 19:18:30 +02:00
lib.rs Add warn(unreachable_pub) to rustc_mir_build. 2024-08-29 20:13:06 +10:00
lints.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00