Skip to content

Commit 335a6e2

Browse files
committed
Remove yet more output from for-loop and ? errors
1 parent 51d3489 commit 335a6e2

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
@@ -816,11 +816,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
816816
&substs,
817817
match lang_item {
818818
hir::LangItem::FuturePoll => ObligationCauseCode::AwaitableExpr,
819-
hir::LangItem::IntoIterIntoIter => ObligationCauseCode::ForLoopIterator,
820-
hir::LangItem::TryTraitFromResidual | hir::LangItem::TryTraitBranch => {
821-
ObligationCauseCode::QuestionMark
819+
hir::LangItem::IteratorNext | hir::LangItem::IntoIterIntoIter => {
820+
ObligationCauseCode::ForLoopIterator
822821
}
823-
_ => traits::ItemObligation(def_id),
822+
hir::LangItem::TryTraitFromOutput
823+
| hir::LangItem::TryTraitFromResidual
824+
| hir::LangItem::TryTraitBranch => ObligationCauseCode::QuestionMark,
824825
},
825826
);
826827
(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)