Skip to content

Please lint on a.eq(b.into()) if a.eq(b) would work #135201

Open
@joshtriplett

Description

@joshtriplett

In the course of investigating crater breakage, I discovered many instances of a pattern that reduces to this:

fn main() {
    let s = String::from("hello");
    assert!(s.eq("hello".into()));
}

This compiles, presumably because "hello".into() has only one possible impl that would work. It breaks if another From impl is brought into scope. For instance, cargo add bstr and add use bstr as _; to the top of that example, and it breaks.

Could we lint against this?

cc @estebank; this is in the same spirit as #129249 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team, which will review and decide on the PR/issue.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions