Skip to content

once fn/proc() allows use-after-move of captured variable #10398

Closed

Description

@ben0x539

and crashes, inevitably.

fn main() {
    let x = ~"foo";
    let f: proc() = proc() {
        let _a = x;
        drop(x);
    };
    f();
}

Activity

  1. huonw commented on Nov 10, 2013

    @huonw
    Contributor
  2. nikomatsakis commented on Nov 11, 2013

    @nikomatsakis
    Contributor

    Looks bad. :) I'll take a look.

  3. alexcrichton commented on Dec 5, 2013

    @alexcrichton
    Member

    Some other code which compiles and shouldn't compile:

    fn foo(_: ~int) {}  
    
    fn main() {         
        let a = ~2;     
        do spawn {      
            loop {      
                foo(a); 
            }           
        }               
    }                   
  4. added a commit that references this issue on Apr 9, 2014
    767ed1a
  5. added a commit that references this issue on Apr 10, 2014
    7fbcb40
  6. added a commit that references this issue on Jun 27, 2024
  7. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

I-crash

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions