]> git.lizzy.rs Git - rust.git/blob - src/test/ui/mismatched_types/closure-arg-count-expected-type-issue-47244.rs
Rollup merge of #89945 - JohnTitor:we-now-specialize-clone-from-slice, r=the8472
[rust.git] / src / test / ui / mismatched_types / closure-arg-count-expected-type-issue-47244.rs
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 }