diff options
| author | Yukang <moorekang@gmail.com> | 2025-01-17 08:19:23 +0800 |
|---|---|---|
| committer | yukang <moorekang@gmail.com> | 2025-02-22 11:45:09 +0800 |
| commit | d6d9c2e7516c687553480a4e171f89dfc22009dd (patch) | |
| tree | 6af8314cda1aacf5b6facb865ef5bbadad20516b | |
| parent | 8cddffb74ef7fa75767c710e9f85bd4389159adb (diff) | |
| download | rust-d6d9c2e7516c687553480a4e171f89dfc22009dd.tar.gz rust-d6d9c2e7516c687553480a4e171f89dfc22009dd.zip | |
Update compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
| -rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 2 | ||||
| -rw-r--r-- | tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index a34f3d27fb6..a31abef4375 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -791,7 +791,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", "_ = ", diff --git a/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr index f9b606cd52d..31acc5bb10e 100644 --- a/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr +++ b/tests/ui/typeck/closure-ty-mismatch-issue-128561.stderr @@ -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 |
