Skip to content

Commit 79749d6

Browse files
committed
Remove yet more output from for-loop and ? errors
1 parent 81a3b90 commit 79749d6

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
810810
&substs,
811811
match lang_item {
812812
hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr,
813-
hir::LangItem::IntoIterIntoIter => ObligationCauseCode::ForLoopIterator,
814-
hir::LangItem::TryTraitFromResidual | hir::LangItem::TryTraitBranch => {
815-
ObligationCauseCode::QuestionMark
813+
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
814+
ObligationCauseCode::ForLoopIterator
816815
}
817-
_ => traits::ItemObligation(def_id),
816+
hir::LangItem::TryTraitFromOutput
817+
| hir::LangItem::TryTraitFromResidual
818+
| hir::LangItem::TryTraitBranch => ObligationCauseCode::QuestionMark,
818819
},
819820
);
820821
(Res::Def(def_kind, def_id), ty)

src/test/ui/issues/issue-33941.stderr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ LL | for _ in HashMap::new().iter().cloned() {}
2323
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
2424
= note: required because of the requirements on the impl of `IntoIterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
2525

26+
<<<<<<< HEAD
2627
error: aborting due to 2 previous errors
28+
=======
29+
error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as Iterator>::Item == &_`
30+
--> $DIR/issue-33941.rs:4:14
31+
|
32+
LL | for _ in HashMap::new().iter().cloned() {}
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference
34+
|
35+
= note: expected tuple `(&_, &_)`
36+
found reference `&_`
37+
= note: required because of the requirements on the impl of `Iterator` for `Cloned<std::collections::hash_map::Iter<'_, _, _>>`
38+
39+
error: aborting due to 3 previous errors
40+
>>>>>>> 330b90f5fc1 (Remove yet more output from `for`-loop and `?` errors)
2741

2842
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)