{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/41790","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/41790/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/41790/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/41790/events","html_url":"https://github.com/rust-lang/rust/issues/41790","id":226788938,"number":41790,"title":"Cannot assign to captured outer variable in an `FnMut` closure diagnostic","user":{"login":"Mark-Simulacrum","id":5047365,"avatar_url":"https://avatars3.githubusercontent.com/u/5047365?v=3","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false},"labels":[{"id":235791,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-06T17:26:56Z","updated_at":"2017-05-06T17:26:56Z","closed_at":null,"body":"```rust\r\nfn foo(mut f: Box<FnMut()>) {\r\n    f();\r\n}\r\n\r\nfn main() {\r\n    let y = true;\r\n    foo(Box::new(move || y = false) as Box<_>);\r\n}\r\n```\r\n\r\nproduces\r\n\r\n```\r\nerror: cannot assign to captured outer variable in an `FnMut` closure\r\n --> test.rs:7:26\r\n  |\r\n7 |     foo(Box::new(move || y = false) as Box<_>);\r\n  |                          ^^^^^^^^^\r\n\r\nerror: aborting due to previous error\r\n```\r\n\r\nbut should produce\r\n\r\n```\r\nerror: cannot assign to captured outer variable in an `FnMut` closure\r\n --> test.rs:7:26\r\n  |\r\n6 |     let y = true;\r\n  |         - use `mut y` here to make mutable\r\n7 |     foo(Box::new(move || y = false) as Box<_>);\r\n  |                          ^^^^^^^^^\r\n\r\nerror: aborting due to previous error\r\n```\r\n\r\ncc @estebank, you implemented a similar change for moves: #41523."}}
{"actor":{"display_login":"Mark-Simulacrum"}}