Skip to content

It is recommended that threads support context transfer and automatically perform clone operations #133795

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

Closed
1057105012 opened this issue Dec 3, 2024 · 3 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team

Comments

@1057105012
Copy link

1057105012 commented Dec 3, 2024

Code

fn main() {
    let (sx, rx) = mpsc::channel();
    let handle = thread::spawn(move |sx, rx| {
        sx.send("hello").unwrap();
    });
    handle.join().unwrap();
}

It is recommended that threads support context. As shown in the figure, the context automatically performs cloning operations, which can avoid code, like this let handle = thread::spawn(move |sx, rx| {} not sx.clone(), rx.clone()。 

This operation can be understood as opening an isolation domain. Or abstract it into a more general concept. Rust allows the creation of isolated domains. All external borrowing in the isolation domain is automatically recognized as a clone operation

@1057105012 1057105012 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2024
@theemathas
Copy link
Contributor

Something similar to this is a 2024H2 project goal.
https://rust-lang.github.io/rust-project-goals/2024h2/ergonomic-rc.html
rust-lang/rust-project-goals#107

@fmease fmease added T-lang Relevant to the language team C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Dec 3, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2024
@fmease
Copy link
Member

fmease commented Dec 3, 2024

@fmease
Copy link
Member

fmease commented Dec 3, 2024

Closing in favor of rust-lang/rust-project-goals#107

@fmease fmease closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team
Projects
None yet
Development

No branches or pull requests

5 participants