Closed
Description
#![feature(unboxed_closures)]
fn to_fn<A, F:Fn<A>>(f: F) -> F { f }
fn main() {
let mut x = 0;
let _f = to_fn(|| x = 42); //~ ERROR cannot assign to `x`
}
help: consider changing this to accept closures that implement `FnMut`
--> $DIR/borrow-immutable-upvar-mutation.rs:15:24
|
LL | let _f = to_fn(|| x = 42);
| ^^^^^^^^^
This is confusing, as it appears to suggest the user change the closure to "accept closures". The span is incorrect: we should use the span of the function to_fn
, not the span of the closure.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint that should be reworked.`#![feature(unboxed_closures)]`Relevant to the compiler team, which will review and decide on the PR/issue.This issue requires a nightly compiler in some way.