Skip to content

Type checker does not eagerly select predicates from where-clauses #5514

Open
@jonas-schievink

Description

@jonas-schievink

The following code fails to infer the type of x, as well as the call to the inherent method as_str:

fn f<T: Into<String>>(u: T) {
    let x = u.into();
    x.as_str();
}

rustc has no problem with this code, since the .into() call will eagerly use the T: Into<String> bound from the where clause. This happens despite plenty of other Into impls existing in the wild and is an intentional Rust feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bugS-blocked-on-new-solverwill be fixed when we will switch to the new trait solverS-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions