diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index d839d9bef8ad..b1d98a48057b 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -810,11 +810,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &substs, match lang_item { hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr, - hir::LangItem::IntoIterIntoIter => ObligationCauseCode::ForLoopIterator, - hir::LangItem::TryTraitFromResidual | hir::LangItem::TryTraitBranch => { - ObligationCauseCode::QuestionMark + hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => { + ObligationCauseCode::ForLoopIterator } - _ => traits::ItemObligation(def_id), + hir::LangItem::TryTraitFromOutput + | hir::LangItem::TryTraitFromResidual + | hir::LangItem::TryTraitBranch => ObligationCauseCode::QuestionMark, }, ); (Res::Def(def_kind, def_id), ty) diff --git a/src/test/ui/issues/issue-33941.stderr b/src/test/ui/issues/issue-33941.stderr index c6650d60c21e..52341517756c 100644 --- a/src/test/ui/issues/issue-33941.stderr +++ b/src/test/ui/issues/issue-33941.stderr @@ -23,6 +23,20 @@ LL | for _ in HashMap::new().iter().cloned() {} = note: required because of the requirements on the impl of `Iterator` for `Cloned>` = note: required because of the requirements on the impl of `IntoIterator` for `Cloned>` +<<<<<<< HEAD error: aborting due to 2 previous errors +======= +error[E0271]: type mismatch resolving ` as Iterator>::Item == &_` + --> $DIR/issue-33941.rs:4:14 + | +LL | for _ in HashMap::new().iter().cloned() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference + | + = note: expected tuple `(&_, &_)` + found reference `&_` + = note: required because of the requirements on the impl of `Iterator` for `Cloned>` + +error: aborting due to 3 previous errors +>>>>>>> 330b90f5fc1 (Remove yet more output from `for`-loop and `?` errors) For more information about this error, try `rustc --explain E0271`.