mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
cb4bb14237
Avoid misleading return-type note for foreign `Fn` callees Fixes rust-lang/rust#155727. The issue occurred because the code that emitted the `Fn`/`FnMut` suggestion only avoided the return-type fallback when it could point at a local callee argument. The local case from rust-lang/rust#125325 was fixed in rust-lang/rust#126226, but nested cross-crate cases could still suggest changing the enclosing function's return type even though the relevant `Fn` requirement came from the callee argument. This is also the broader diagnostic shape discussed in rust-lang/rust#119985. This PR checks the instantiated callee predicates for an exact `Fn` bound on the closure argument, and extends `wrong-closure-arg-suggestion-125325` with cross-crate function and method cases for that path.