Skip to content

Confusing error messages when trying to implement Display for [Owntype] #34075

Closed
@johanneshoehn

Description

@johanneshoehn

For instance impl fmt::Display for [PathSegType] { leads to:

error: the impl does not reference any types defined in this crate; only traits defined in the current crate can be implemented for arbitrary types [E0117]

Here the error message could be more helpful. The impl actually does reference a type local to the crate, but only as part of non-local type.

The error message gets way more confusing if you use Types with parameters, for instance impl<T: Display + Copy> fmt::Display for [PathSeg<T>] { leads to:

error: type parameter T must be used as the type parameter for some local type (e.g. MyStruct<T>); only traits defined in the current crate can be implemented for a type parameter [E0210]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions