diff options
| author | bors <bors@rust-lang.org> | 2022-09-19 07:41:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-19 07:41:54 +0000 |
| commit | 503e19d01e941b88bf6d5b28e9108d046abcfa2d (patch) | |
| tree | f2b6f6bd176a03ff1c4e0b2588707d733eecb14c /compiler/rustc_trait_selection/src | |
| parent | efa717bc2d82c19c6957f362a936a6f95169d138 (diff) | |
| parent | 44738ee336f72e683b2c24dac22b919567ec03a7 (diff) | |
| download | rust-503e19d01e941b88bf6d5b28e9108d046abcfa2d.tar.gz rust-503e19d01e941b88bf6d5b28e9108d046abcfa2d.zip | |
Auto merge of #101629 - compiler-errors:issue-101623, r=sanxiyn
Be careful about `expr_ty_adjusted` when noting block tail type Fixes #101623
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 13d9c160038..d90b77fc556 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -2714,12 +2714,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { Some(t) if t.hir_owner == parent_id => t, _ => self.tcx.typeck(parent_id), }; - let ty = typeck_results.expr_ty_adjusted(expr); - let span = expr.peel_blocks().span; + let expr = expr.peel_blocks(); + let ty = typeck_results.expr_ty_adjusted_opt(expr).unwrap_or(tcx.ty_error()); + let span = expr.span; if Some(span) != err.span.primary_span() { err.span_label( span, - &if ty.references_error() { + if ty.references_error() { String::new() } else { format!("this tail expression is of type `{:?}`", ty) |
