Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Truncate box deref in move closures #50

Closed
arora-aman opened this issue Jun 16, 2021 · 0 comments · Fixed by rust-lang/rust#86445
Closed

Truncate box deref in move closures #50

arora-aman opened this issue Jun 16, 2021 · 0 comments · Fixed by rust-lang/rust#86445
Assignees
Labels
bug Something isn't working

Comments

@arora-aman
Copy link
Member

#![feature(capture_disjoint_fields)]
#![feature(rustc_attrs)]

struct S(i32, String);

fn main() {
    let x = Box::new(S(0, String::new()));
    
    let c = move || {
        println!("{}, x.1); // currently capture x.1 by Move
    };
}

This should capture x by move.

@arora-aman arora-aman self-assigned this Jun 16, 2021
@arora-aman arora-aman added the bug Something isn't working label Jun 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 27, 2021
2229: Capture box completely in move closures

Even if the content from box is used in a sharef-ref context,
we capture the box entirerly.

This is motivated by:
1) We only capture data that is on the stack.
2) Capturing data from within the box might end up moving more data than
the user anticipated.

Closes rust-lang/project-rfc-2229#50

r? `@nikomatsakis`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants