]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.fixed
Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup
[rust.git] / src / test / ui / mismatched_types / closure-arg-count-expected-type-issue-47244.fixed
1 // Regression test for #47244: in this specific scenario, when the
2 // expected type indicated 1 argument but the closure takes two, we
3 // would (early on) create type variables for the type of `b`. If the
4 // user then attempts to invoke a method on `b`, we would get an error
5 // saying that the type of `b` must be known, which was not very
6 // helpful.
7
8 // run-rustfix
9
10 use std::collections::HashMap;
11
12 fn main() {
13     let mut m = HashMap::new();
14     m.insert("foo", "bar");
15
16     let _n = m.iter().map(|(_, b)| {
17         //~^ ERROR closure is expected to take a single 2-tuple
18         b.to_string()
19     });
20 }