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

Comments

Projects
None yet
7 participants
@frankmcsherry
Copy link
Contributor

frankmcsherry commented Apr 14, 2015

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.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Dec 1, 2016

Needs a P- tag.

@brson brson added the P-medium label Dec 1, 2016

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 1, 2016

triage: P-medium

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Dec 1, 2016

oh, sorry :)

@arielb1

This comment has been minimized.

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

This comment has been minimized.

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

Auto merge of #55018 - euclio:issue-24421, r=alexcrichton
add test for #24421

Fixes #24421.

Also removes a README which points to a non-existent directory.

@bors bors closed this in #55018 Oct 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.