-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.