-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
#![allow(unused)]
fn main() {
let a = 0;
let mut b = None;
move || {
b = Some(&a);
};
}Current output
error[E0521]: borrowed data escapes outside of closure
--> src/main.rs:6:9
|
4 | let mut b = None;
| ----- `b` declared here, outside of the closure body
5 | move || {
6 | b = Some(&a);
| ^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0521`.Desired output
Rationale and extra context
When the compiler points to a piece of code, it usually explains how that code is relevant. Here, however, the compiler just silently points there for some reason.
Other cases
Rust Version
Reproducible on the playground with version 1.93.0-nightly (2025-11-01 bd3ac0330018c23b111b)Anything else?
No response
KisaragiEffective
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.