We're not warning against fn ptr and wide raw ptr nested inside ADTs #116929
Closed
Description
opened on Oct 19, 2023
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