Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closure parameter inference and lifetime elision mayhem #24421

Closed
frankmcsherry opened this issue Apr 14, 2015 · 5 comments
Closed

Closure parameter inference and lifetime elision mayhem #24421

frankmcsherry opened this issue Apr 14, 2015 · 5 comments
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@frankmcsherry
Copy link
Contributor

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.

@steveklabnik steveklabnik added the A-closures Area: Closures (`|…| { … }`) label Apr 16, 2015
@brson brson added I-wrong T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2016
@brson
Copy link
Contributor

brson commented Dec 1, 2016

Needs a P- tag.

@brson brson added the P-medium Medium priority label Dec 1, 2016
@nikomatsakis
Copy link
Contributor

triage: P-medium

@rust-highfive rust-highfive added P-medium Medium priority and removed P-medium Medium priority I-nominated labels Dec 1, 2016
@nikomatsakis
Copy link
Contributor

oh, sorry :)

@Mark-Simulacrum Mark-Simulacrum added C-bug Category: This is a bug. and removed C-enhancement Category: An issue proposing an enhancement or a PR with one. I-wrong labels Jul 22, 2017
@arielb1 arielb1 added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Nov 14, 2017
@arielb1
Copy link
Contributor

arielb1 commented Nov 14, 2017

Looks like it was caused by the same "unexpected capture" issue as #38714 - it works on nightly.

@arielb1
Copy link
Contributor

arielb1 commented Nov 14, 2017

This still looks like a distinct "family of examples", so I'll at least like it to be added to the test for that issue.

euclio added a commit to euclio/rust that referenced this issue Oct 12, 2018
bors added a commit that referenced this issue Oct 14, 2018
add test for #24421

Fixes #24421.

Also removes a README which points to a non-existent directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants