Skip to content

Rereborrowing loses lifetime information. #4285

Closed
@stevenblenkinsop

Description

@stevenblenkinsop

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions