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

A struct defined to hold a closure accepts a proc in its constructor #11515

Closed
bstrie opened this issue Jan 13, 2014 · 7 comments
Closed

A struct defined to hold a closure accepts a proc in its constructor #11515

bstrie opened this issue Jan 13, 2014 · 7 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-low Low priority

Comments

@bstrie
Copy link
Contributor

bstrie commented Jan 13, 2014

This seems like it shouldn't be possible:

struct Test<'s> {
    func: 's ||
}

fn main() {
    let test = ~Test { func: proc() {} };
}

...but it compiles just fine on 0.9.

@brson
Copy link
Contributor

brson commented Jan 15, 2014

Presumably with horrible results? Nominating.

@nikomatsakis
Copy link
Contributor

cc me

@pnkfelix
Copy link
Member

Accepting for P-backcompat-lang.

@nikomatsakis
Copy link
Contributor

presumably a symptom of the current semi-hacky integration of proc into rustc

@eddyb
Copy link
Member

eddyb commented Apr 11, 2014

Can't reproduce anymore, should we close this?

@alexcrichton
Copy link
Member

I don't think it should be closed quite yet, the error message is pretty awful:

foo.rs:6:30: 6:39 error: borrowed value does not live long enough
foo.rs:6     let test = ~Test { func: proc() {} };
                                      ^~~~~~~~~
foo.rs:5:11: 7:2 note: reference must be valid for the block at 5:10...
foo.rs:5 fn main() {
foo.rs:6     let test = ~Test { func: proc() {} };
foo.rs:7 }
foo.rs:6:9: 6:41 note: ...but borrowed value is only valid for the statement at 6:8
foo.rs:6     let test = ~Test { func: proc() {} };
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

Because this no longer compiles successfully, nominating go go from 1.0 backcompat-lang to P-low

@pnkfelix
Copy link
Member

Recategorizing as P-low, not on 1.0 milestone.

@pnkfelix pnkfelix removed this from the 1.0 milestone Apr 17, 2014
@brson brson removed the I-nominated label Apr 17, 2014
bors added a commit that referenced this issue Apr 28, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 25, 2023
…=Jarcho

[`filter_map_bool_then`]: include multiple derefs from adjustments

In rust-lang#11506 this lint was improved to suggest one deref if the bool is behind references (fixed the FP rust-lang#11503), however it might need multiple dereferences if the bool is behind multiple layers of references or custom derefs. E.g. `&&&bool` needs `***b`.

changelog: [`filter_map_bool_then`]: suggest as many dereferences as there are needed to get to the bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. P-low Low priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants