Commit 4f8a3ff
authored
Rollup merge of #151035 - issue-150693-closure-arg-suggestion, r=jieyouxu
Don't suggest replacing closure parameter with type name
When a closure has an inferred parameter type like `|ch|` and the expected type differs in borrowing (e.g., `char` vs `&char`), the suggestion would incorrectly propose `|char|` instead of something valid like `|ch: char|`.
This happened because the code couldn't walk explicit `&` references in the HIR when the type is inferred, and fell back to replacing the entire parameter span with the expected type name.
Fix by only emitting the suggestion when we can properly identify the `&` syntax to remove.
Fixes rust-lang/rust#1506930 file changed
0 commit comments