Skip to content

We're not warning against fn ptr and wide raw ptr nested inside ADTs #116929

Closed
@RalfJung

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.

Cc @oli-obk @lcnr

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions