Suggest associated type when the specified one cannot be found Fixes #67386, so code like this: ``` use std::ops::Deref; fn homura<T: Deref<Trget = i32>>(_: T) {} fn main() {} ``` results in: ``` error[E0220]: associated type `Trget` not found for `std::ops::Deref` --> type-binding.rs:6:20 | 6 | fn homura<T: Deref<Trget = i32>>(_: T) {} | ^^^^^^^^^^^ help: there is an associated type with a similar name: `Target` error: aborting due to previous error ``` (The `help` is new) I used an `all_candidates: impl Fn() -> Iterator<...>` instead of `collect`ing to avoid the cost of allocating the Vec when no errors are found, at the expense of a little added complexity. r? @estebank
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc guide.