Skip to content

Commit

Permalink
Update compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Browse files Browse the repository at this point in the history
Co-authored-by: Esteban Kuber <[email protected]>
  • Loading branch information
chenyukang and estebank committed Jan 17, 2025
1 parent e3a7cc3 commit 9a6d414
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
ExprKind::Path(..) | ExprKind::Lit(_) if parent_is_closure => {
err.span_suggestion(
err.span_suggestion_verbose(
expression.span.shrink_to_lo(),
"consider ignoring the value",
"_ = ",
Expand Down
10 changes: 6 additions & 4 deletions tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ error[E0308]: mismatched types
--> $DIR/closure-ty-mismatch-issue-128561.rs:2:32
|
LL | b"abc".iter().for_each(|x| x);
| ^
| |
| expected `()`, found `&u8`
| help: consider ignore the value here: `_ =`
| ^ expected `()`, found `&u8`
|
help: consider ignoring the value
|
LL | b"abc".iter().for_each(|x| _ = x);
| +++

error[E0308]: mismatched types
--> $DIR/closure-ty-mismatch-issue-128561.rs:4:32
Expand Down

0 comments on commit 9a6d414

Please sign in to comment.