diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-30 14:33:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-30 14:33:52 +0200 |
| commit | 65bdfe3b41c862dd9413c49dfba884c6622897ab (patch) | |
| tree | ddc3c7ad0e8d625911aafb0b9b714d403b4b584b /compiler | |
| parent | 9bb3832ebd7aa820366598187862fd6370aefd9f (diff) | |
| parent | 2e25c2346b9cf58c3c30375bd6e6defef1c11f07 (diff) | |
| download | rust-65bdfe3b41c862dd9413c49dfba884c6622897ab.tar.gz rust-65bdfe3b41c862dd9413c49dfba884c6622897ab.zip | |
Rollup merge of #97531 - compiler-errors:for-loop-pat-mismatch, r=davidtwco
Note pattern mismatch coming from `for` loop desugaring Fixes #97163
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_infer/src/infer/error_reporting/mod.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 11c893a7cb6..e156930cc89 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -609,7 +609,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { if !matches!(ty.kind(), ty::Infer(ty::InferTy::TyVar(_) | ty::InferTy::FreshTy(_))) { // don't show type `_` - err.span_label(span, format!("this expression has type `{}`", ty)); + if span.desugaring_kind() == Some(DesugaringKind::ForLoop) + && let ty::Adt(def, substs) = ty.kind() + && Some(def.did()) == self.tcx.get_diagnostic_item(sym::Option) + { + err.span_label(span, format!("this is an iterator with items of type `{}`", substs.type_at(0))); + } else { + err.span_label(span, format!("this expression has type `{}`", ty)); + } } if let Some(ty::error::ExpectedFound { found, .. }) = exp_found && ty.is_box() && ty.boxed_ty() == found |
