Closed
Description
This is either a regression of #45685 or it was closed prematurely.
Fairly minimal reproducer:
use std::collections::hash_map::HashMap;
fn foo(parameters: &HashMap<String, String>) -> bool {
parameters
.get(&"key".into())
.and_then(|found: &String| {
Some(false)
})
.unwrap_or(false)
}
->
error[E0283]: type annotations needed for `&std::string::String`
--> src/lib.rs:6:20
|
6 | .and_then(|found: &String| {
| ^^^^^ consider giving this closure parameter the explicit type `&std::string::String`, where the type parameter `std::string::String` is specified
|
= note: cannot resolve `std::string::String: std::borrow::Borrow<_>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0283`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
I'm still not entirely sure what is actually wrong here - is it the lifetime as in #22340? Anyhow - the message doesn't refer to any T that needs to be specified, and the named explicit type is not sufficient to fix the issue even when given.
Happens with nightly too.
Metadata
Metadata
Assignees
Labels
Area: Closures (`|…| { … }`)Area: Messages for errors, warnings, and lintsArea: Type inferenceCategory: An issue proposing an enhancement or a PR with one.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.