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

Rereborrowing loses lifetime information. #4285

Closed
stevenblenkinsop opened this issue Dec 25, 2012 · 2 comments
Closed

Rereborrowing loses lifetime information. #4285

stevenblenkinsop opened this issue Dec 25, 2012 · 2 comments
Labels
A-lifetimes Area: Lifetimes / regions
Milestone

Comments

@stevenblenkinsop
Copy link

This code fails to compile:
fn rereborrow(v: &r/int) -> &r/int { &_&_v }

fn main() {}

With error:
test.rs:1:38: 1:42 error: illegal borrow: borrowed value does not live long enough
test.rs:1 fn rereborrow(v: &r/int) -> &r/int { &_&v }
^~~~
test.rs:1:35: 1:44 note: borrowed pointer must be valid for the lifetime &r as defined on the block at 1:35...
test.rs:1 fn rereborrow(v: &r/int) -> &r/int { &
&v }
^~~~~~~~~
test.rs:1:35: 1:44 note: ...but borrowed value is only valid for the block at 1:35
test.rs:1 fn rereborrow(v: &r/int) -> &r/int { &
&_v }
^~~~~~~~~
error: aborting due to previous error

shell returned 101

@catamorphism
Copy link
Contributor

I'm not sure if this is by design or not -- we'll have to wait for @nikomatsakis to answer that.

@nikomatsakis
Copy link
Contributor

I believe this is a duplicate of #3148 which also suggests a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

3 participants