Skip to content

Confusing error message when trying to implement From<GenericLocalType<T>> for Option<T> #65247

Closed
@repnop

Description

@repnop

I have a local type:

#[derive(Debug, Deserialize)]
#[serde(untagged)]
enum BadOption<T> {
    Some(T),
    None(Value),
}

and I want to impl<T> From<BadOption<T>> for Option<T> but the error message suggests that T isn't being used as the type parameter for a local type

type parameter T must be used as the type parameter for some local type

Reproduction: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9abd2ab4860140be2859d4767fc027f8

Full error:

error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
  --> src/main.rs:11:1
   |
11 | impl<T> From<BadOption<T>> for Option<T> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `T` must be used as the type parameter for some local type
   |
   = note: only traits defined in the current crate can be implemented for a type parameter

Metadata

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-confusingDiagnostics: Confusing error or lint that should be reworked.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