Closed
Description
I found a gap in our match forward-compatibility warnings:
type T = (*const [i32], i32);
const C: T = (unsafe { std::mem::transmute((0usize, 0usize)) }, 0);
fn test(x: T) -> bool {
matches!(x, C)
}
This should warn but doesn't.
The reason is that here we are only checking the top-level type to be a wide raw ptr or fn ptr, we are not recursing.
The fix IMO is to reject those types in compiler/rustc_trait_selection/src/traits/structural_match.rs
, which already recurses the type.
Activity
oli-obk commentedon Oct 19, 2023
That would warn on
Option<String>
, which can be used at None valueRalfJung commentedon Oct 19, 2023
It would? That's surprising, since valtree construction will succeed for
None: Option<String>
.So that could be used as a signal not to lint.
Auto merge of rust-lang#116930 - RalfJung:raw-ptr-match, r=<try>
Auto merge of rust-lang#116930 - RalfJung:raw-ptr-match, r=davidtwco
Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco
Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco
Auto merge of #116930 - RalfJung:raw-ptr-match, r=davidtwco