Please lint on `a.eq(b.into())` if `a.eq(b)` would work
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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 https://github.com/rust-lang/rust/pull/129249/ .
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided fn main example and reproduce the behavior, including adding bstr and use bstr as _;. Read the linked PR for the intended linting precedent. Done means the problematic form is diagnosed while the direct a.eq(b) form remains accepted, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100