]> git.lizzy.rs Git - rust.git/blob - tests/ui/inference/issue-71732.rs
Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez
[rust.git] / tests / ui / inference / issue-71732.rs
1 // Regression test for #71732, it used to emit incorrect diagnostics, like:
2 // error[E0283]: type annotations needed
3 //  --> src/main.rs:5:10
4 //   |
5 // 5 |         .get(&"key".into())
6 //   |          ^^^ cannot infer type for struct `String`
7 //   |
8 //   = note: cannot satisfy `String: Borrow<_>`
9 // help: consider specifying the type argument in the method call
10 //   |
11 // 5 |         .get::<Q>(&"key".into())
12 //   |
13
14 use std::collections::hash_map::HashMap;
15
16 fn foo(parameters: &HashMap<String, String>) -> bool {
17     parameters
18         .get(&"key".into())
19         //~^ ERROR type annotations needed
20         .and_then(|found: &String| Some(false))
21         .unwrap_or(false)
22 }
23
24 fn main() {}