-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.