Skip to content

Wishlist: compiler should give hint when trying to use Box<Trait> as Trait #42356

@jsgf

Description

@jsgf

If I have a function:

fn foo<F: Foo>(f: F) { ... }

and I pass it Box<Foo>, this fails because Box<Foo> doesn't actually implement the Foo trait. Ideally it should, but as a stop-gap the compiler should hint at that problem, because it wasn't obvious to me that a boxed trait object doesn't implement that trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemA-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions