Remove yet more output from for-loop and ? errors

This commit is contained in:
Esteban Kuber 2021-11-16 02:50:30 +00:00
parent 81a3b90afd
commit 79749d64fa
2 changed files with 19 additions and 4 deletions

View file

@ -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)

View file

@ -23,6 +23,20 @@ LL | for _ in HashMap::new().iter().cloned() {}
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
<<<<<<< HEAD
error: aborting due to 2 previous errors
=======
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> 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<std::collections::hash_map::Iter<'_, _, _>>`
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`.