-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.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.P-mediumMedium priorityMedium priorityT-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
If you throw the following code into playpen, in the fourth case (by my reading of the error message) Rust determines an incompatible number of lifetime parameters for<'r> core::ops::Fn<(&'r u64, &'r u64)>
vs. for<'r,'r> core::ops::Fn<(&'r u64, &'r u64)>
).
fn test<F: Fn(&u64, &u64)>(f: F) {}
fn main() {
test(|x, y | {}); // works
test(|x:&u64, y:&u64| {}); // works
test(|x:&u64, y | {}); // works
test(|x, y:&u64| {}); // no works
}
I won't try to explain how mysterious this was, manifesting as a "sorry, you don't implement that trait" error (because the closure was not matching the type) without explaining what was awry.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.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.P-mediumMedium priorityMedium priorityT-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.