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

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

Closed
ben0x539 opened this issue Nov 10, 2013 · 3 comments · Fixed by #13413
Closed

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

ben0x539 opened this issue Nov 10, 2013 · 3 comments · Fixed by #13413
Assignees
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@ben0x539
Copy link
Contributor

and crashes, inevitably.

fn main() {
    let x = ~"foo";
    let f: proc() = proc() {
        let _a = x;
        drop(x);
    };
    f();
}
@huonw
Copy link
Member

huonw commented Nov 10, 2013

cc @nikomatsakis

@nikomatsakis
Copy link
Contributor

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

@alexcrichton
Copy link
Member

Some other code which compiles and shouldn't compile:

fn foo(_: ~int) {}  

fn main() {         
    let a = ~2;     
    do spawn {      
        loop {      
            foo(a); 
        }           
    }               
}                   

bors added a commit that referenced this issue Apr 10, 2014
This fixes the categorization of the upvars of procs (represented internally
as once fns) to consider usage to require a loan. In doing so, upvars are no
longer allowed to be moved out of repeatedly in loops and such.

Closes #10398
Closes #12041
Closes #12127
flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 27, 2024
Run a diff of lintcheck against the merge base for pull requests

changelog: none
<!-- changelog_checked -->

This is an MVP of sorts, it consists of rust-lang#9764 + a GitHub action that feeds the output to the [job summary](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary). It doesn't yet do anything fancy like `--recursive` or adding comments to the PR, so you'd have to click through to the action to see the results

Example output of a change (Alexendoo/rust-clippy@0be1ab8): https://github.com/Alexendoo/rust-clippy/actions/runs/4264858870#summary-11583333018

r? `@flip1995`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants