hir_typeck: be more conservative in making "note caller chooses ty param" note by jieyouxu · Pull Request #126558 · rust-lang/rust (original) (raw)
In #122195 I added a "caller chooses ty for type param" note for when the return expression type a.k.a. found type does not match the expected return type.
#126547 found that this note was confusing when the found return type contains the expected type, e.g.
fn f(t: &T) -> T { t }
because the found return type &T
will always be different from the expected return type T
, so the note was needlessly redundant and confusing.
This PR addresses that by not making the note if the found return type contains the expected return type.
r? @fmease (since you reviewed the original PR)
Fixes #126547