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

Mutability of variables captured by procs is ignored #12260

Closed
huonw opened this issue Feb 14, 2014 · 3 comments
Closed

Mutability of variables captured by procs is ignored #12260

huonw opened this issue Feb 14, 2014 · 3 comments

Comments

@huonw
Copy link
Member

huonw commented Feb 14, 2014

fn main() {
    let mut x = 1;
    proc() { x = 2 };
}
proc-mut.rs:3:14: 3:15 error: cannot assign to immutable captured outer variable in a heap closure
proc-mut.rs:3     proc() { x = 2 };
                           ^
@huonw huonw added the I-wrong label Feb 14, 2014
@emberian
Copy link
Member

cc @nikomatsakis @pnkfelix

@alexcrichton
Copy link
Member

Closing as a dupe of #11958, moving the example to that bug.

@huonw
Copy link
Member Author

huonw commented Feb 15, 2014

Closing in sloooowww motion.

@huonw huonw closed this as completed Feb 15, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
…in-macro-expansion, r=lnicola

ide: insert whitespace between 'mut' and 'self' in macro expansion

fixes rust-lang#12260
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 26, 2024
Take lifetime extension into account in `ref_as_ptr`

fixes rust-lang#12255

This should be merged upstream as well. Changing `let x = &temp as *const _` into `let x = from_ref(&temp)` is UB.

changelog: `ref_as_ptr`: Take lifetime extension into account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants