Skip to content

Proc lifetime bug #11925

Closed
Closed
@bvssvni

Description

@bvssvni
fn main() {
    let r = {
        let x = 42;
        let f = proc() &x;
        f()
    };

    // Prints out '&1', but should give a compiler error 'borrowed value does not live long enough'.
    println!("{:?}", r);
}

Activity

lilyball

lilyball commented on Jan 30, 2014

@lilyball
Contributor

This can segfault too, if you change what x is.

fn main() {
    let r = {
        let x = ~42;
        let f = proc() &x;
        f()
    };

    println!("{:?}", r);
}

cc @nikomatsakis

zr40

zr40 commented on Jan 30, 2014

@zr40
Contributor

Might be related to #10398.

nikomatsakis

nikomatsakis commented on Jan 31, 2014

@nikomatsakis
Contributor

I'll take a look.

alexcrichton

alexcrichton commented on Mar 1, 2014

@alexcrichton
Member

This has been fixed, flagging as needstest.

added a commit that references this issue on Mar 6, 2014
13e10f5
added a commit that references this issue on Mar 6, 2014

auto merge of #12738 : alexcrichton/rust/needstest, r=brson,just

0e95b08
flaper87

flaper87 commented on Mar 7, 2014

@flaper87
Contributor

a small description in the test files explaining what the test does would have been nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsA-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @lilyball@flaper87@alexcrichton@nikomatsakis@zr40

      Issue actions

        Proc lifetime bug · Issue #11925 · rust-lang/rust