{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/52941","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/52941/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/52941/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/52941/events","html_url":"https://github.com/rust-lang/rust/issues/52941","id":346537041,"node_id":"MDU6SXNzdWUzNDY1MzcwNDE=","number":52941,"title":"Unclear error E0594","user":{"login":"StyMaar","id":5692308,"node_id":"MDQ6VXNlcjU2OTIzMDg=","avatar_url":"https://avatars0.githubusercontent.com/u/5692308?v=4","gravatar_id":"","url":"https://api.github.com/users/StyMaar","html_url":"https://github.com/StyMaar","followers_url":"https://api.github.com/users/StyMaar/followers","following_url":"https://api.github.com/users/StyMaar/following{/other_user}","gists_url":"https://api.github.com/users/StyMaar/gists{/gist_id}","starred_url":"https://api.github.com/users/StyMaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StyMaar/subscriptions","organizations_url":"https://api.github.com/users/StyMaar/orgs","repos_url":"https://api.github.com/users/StyMaar/repos","events_url":"https://api.github.com/users/StyMaar/events{/privacy}","received_events_url":"https://api.github.com/users/StyMaar/received_events","type":"User","site_admin":false},"labels":[{"id":235791,"node_id":"MDU6TGFiZWwyMzU3OTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-08-01T10:16:03Z","updated_at":"2018-08-02T07:09:23Z","closed_at":"2018-08-02T07:09:23Z","author_association":"NONE","body":"When attempting to mutate a field of a borrowed struct (with a shared reference `&`) we get the unhelpful E5094 error :\r\n\r\n> error[E0594]: cannot assign to field `reagent.unreserved_volume` of immutable **binding** [emphasis mine]\r\n\r\nSample code : \r\n\r\n```\r\nfn main() {\r\n    let foo = &Bar{x: 5}; // or any function that returns a shared reference\r\n    foo.x -= 12;\r\n}\r\n\r\nstruct Bar {\r\n    x: i32\r\n}\r\n```\r\n\r\nError : \r\n\r\n>  |     foo.x -= 12;\r\n    |     ^^^^^^^^^^^ cannot mutably borrow field of immutable binding\r\n\r\n\r\nSince the compiler complains about a “binding” being immutable, my reflex was to add a `mut` at `foo`'s declaration site : \r\n\r\n```\r\nfn main() {\r\n    let mut foo = &Bar{x: 5}; // or any function that returns a shared reference\r\n    foo.x -= 12;\r\n}\r\n\r\nstruct Bar {\r\n    x: i32\r\n}\r\n```\r\n\r\nWhich didn't change anything. (except adding a warning that I didn't notice)\r\n\r\nThe problem here, is that the error message is complaining about an immutable **binding** whereas it should complain about an immutable (or shared) **reference**.\r\n\r\nTo add insult to injury, the error E0594 doesn't exist in the [error index](https://doc.rust-lang.org/stable/error-index.html#E0594) and `rustc --explain E0594` returns the laconic\r\n> error: no extended information for E0594\r\n\r\n## Meta\r\n\r\n`rustc --version --verbose`:\r\n\r\nrustc 1.29.0-nightly (e94df4acb 2018-07-31)\r\nbinary: rustc\r\ncommit-hash: e94df4acb4c3f42fdc224a7164b63a99240add1e\r\ncommit-date: 2018-07-31\r\nhost: x86_64-unknown-linux-gnu\r\nrelease: 1.29.0-nightly\r\nLLVM version: 7.0\r\n\r\nThe behavior is the same on Stable 1.27.2 though."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/409828811","html_url":"https://github.com/rust-lang/rust/issues/52941#issuecomment-409828811","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/52941","id":409828811,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTgyODgxMQ==","user":{"login":"StyMaar","id":5692308,"node_id":"MDQ6VXNlcjU2OTIzMDg=","avatar_url":"https://avatars0.githubusercontent.com/u/5692308?v=4","gravatar_id":"","url":"https://api.github.com/users/StyMaar","html_url":"https://github.com/StyMaar","followers_url":"https://api.github.com/users/StyMaar/followers","following_url":"https://api.github.com/users/StyMaar/following{/other_user}","gists_url":"https://api.github.com/users/StyMaar/gists{/gist_id}","starred_url":"https://api.github.com/users/StyMaar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StyMaar/subscriptions","organizations_url":"https://api.github.com/users/StyMaar/orgs","repos_url":"https://api.github.com/users/StyMaar/repos","events_url":"https://api.github.com/users/StyMaar/events{/privacy}","received_events_url":"https://api.github.com/users/StyMaar/received_events","type":"User","site_admin":false},"created_at":"2018-08-02T07:09:23Z","updated_at":"2018-08-02T07:09:23Z","author_association":"NONE","body":"Thanks for your answers. I think I can close the issue."}}
{"actor":{"display_login":"StyMaar"}}