Skip to content

Error uses parameter name out of context: cannot infer type for U #40944

Closed
@kornelski

Description

@kornelski

The message is technically correct, but it refers to a generic name U that is not present in user's source code, and has no meaning in the current context.

fn main() {
    assert_eq!("bar".into(), "foo".into());
}

error[E0282]: unable to infer enough type information about U
cannot infer type for U

It's even weirder that the type U is not in Into<T>'s definition, but comes from somewhere else inside stdlib.

pub trait Into<T> {
    fn into(self) -> T;
}

It would be clearer if rustc has shown Into<U> instead, or perhaps the stdlib implementation could rename the cryptic U to something self-explanatory like TypeToBeConvertedInto.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions