Skip to content

Confusing error when using unsized types without indirection #28653

Closed

Description

fn foo(arg: Foo) {} //Foo is a trait
fn bar (arg: [i32]) {}
fn quz (arg: str) {}

All those functions return the following error: the trait core::marker::Sized is not implemented for the type...
This is confusing for a beginner, because it makes you think you need to implement a trait to make it work. The message could suggest using &Foo/&[i32]/&str instead.

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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.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