This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 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 ( ) ) //~ ERROR: type annotations needed
19+ . and_then ( |found : & String | Some ( false ) )
20+ . unwrap_or ( false )
21+ }
22+
23+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0283]: type annotations needed
2+ --> $DIR/issue-71732.rs:18:10
3+ |
4+ LL | .get(&"key".into())
5+ | ^^^ ------------ this method call resolves to `T`
6+ | |
7+ | cannot infer type for type parameter `Q` declared on the associated function `get`
8+ |
9+ = note: cannot satisfy `String: Borrow<_>`
10+
11+ error: aborting due to previous error
12+
13+ For more information about this error, try `rustc --explain E0283`.
You can’t perform that action at this time.
0 commit comments