-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Description
fn foo(mut f: Box<FnMut()>) {
f();
}
fn main() {
let y = true;
foo(Box::new(move || y = false) as Box<_>);
}
produces
error: cannot assign to captured outer variable in an `FnMut` closure
--> test.rs:7:26
|
7 | foo(Box::new(move || y = false) as Box<_>);
| ^^^^^^^^^
error: aborting due to previous error
but should produce
error: cannot assign to captured outer variable in an `FnMut` closure
--> test.rs:7:26
|
6 | let y = true;
| - use `mut y` here to make mutable
7 | foo(Box::new(move || y = false) as Box<_>);
| ^^^^^^^^^
error: aborting due to previous error
cc @estebank, you implemented a similar change for moves: #41523.
estebank, pop, jD91mZM2 and torkleyy
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics