{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/46020","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/46020/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/46020/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/46020/events","html_url":"https://github.com/rust-lang/rust/issues/46020","id":274329958,"node_id":"MDU6SXNzdWUyNzQzMjk5NTg=","number":46020,"title":"MIR-borrowck: add \"consider changing this to `mut x`\" note, as in AST borrowck","user":{"login":"arielb1","id":1830974,"node_id":"MDQ6VXNlcjE4MzA5NzQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1830974?v=4","gravatar_id":"","url":"https://api.github.com/users/arielb1","html_url":"https://github.com/arielb1","followers_url":"https://api.github.com/users/arielb1/followers","following_url":"https://api.github.com/users/arielb1/following{/other_user}","gists_url":"https://api.github.com/users/arielb1/gists{/gist_id}","starred_url":"https://api.github.com/users/arielb1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arielb1/subscriptions","organizations_url":"https://api.github.com/users/arielb1/orgs","repos_url":"https://api.github.com/users/arielb1/repos","events_url":"https://api.github.com/users/arielb1/events{/privacy}","received_events_url":"https://api.github.com/users/arielb1/received_events","type":"User","site_admin":false},"labels":[{"id":171502053,"node_id":"MDU6TGFiZWwxNzE1MDIwNTM=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-borrow-checker","name":"A-borrow-checker","color":"d7e102","default":false},{"id":235791,"node_id":"MDU6TGFiZWwyMzU3OTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102","default":false},{"id":234902,"node_id":"MDU6TGFiZWwyMzQ5MDI=","url":"https://api.github.com/repos/rust-lang/rust/labels/C-enhancement","name":"C-enhancement","color":"f5f1fd","default":false},{"id":67766349,"node_id":"MDU6TGFiZWw2Nzc2NjM0OQ==","url":"https://api.github.com/repos/rust-lang/rust/labels/E-mentor","name":"E-mentor","color":"02E10C","default":false},{"id":867465998,"node_id":"MDU6TGFiZWw4Njc0NjU5OTg=","url":"https://api.github.com/repos/rust-lang/rust/labels/NLL-diagnostics","name":"NLL-diagnostics","color":"f799ea","default":false},{"id":211668100,"node_id":"MDU6TGFiZWwyMTE2NjgxMDA=","url":"https://api.github.com/repos/rust-lang/rust/labels/T-compiler","name":"T-compiler","color":"bfd4f2","default":false},{"id":693557751,"node_id":"MDU6TGFiZWw2OTM1NTc3NTE=","url":"https://api.github.com/repos/rust-lang/rust/labels/WG-compiler-nll","name":"WG-compiler-nll","color":"c2e0c6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/rust-lang/rust/milestones/46","html_url":"https://github.com/rust-lang/rust/milestone/46","labels_url":"https://api.github.com/repos/rust-lang/rust/milestones/46/labels","id":3049042,"node_id":"MDk6TWlsZXN0b25lMzA0OTA0Mg==","number":46,"title":"NLL: diagnostic parity","description":"Error messages when using the new, MIR-based borrow checker should be as good or better than the old ones.","creator":{"login":"nikomatsakis","id":155238,"node_id":"MDQ6VXNlcjE1NTIzOA==","avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":6,"state":"closed","created_at":"2018-01-19T16:48:35Z","updated_at":"2018-05-29T13:36:58Z","due_on":null,"closed_at":"2018-03-14T20:41:12Z"},"comments":7,"created_at":"2017-11-15T22:37:41Z","updated_at":"2018-06-21T18:15:23Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Currently, when you try to access an immutable local, AST borrowck suggests that you should change it to `mut x`, for example:\r\n\r\n```Rust\r\nfn main() {\r\n    let x = 0;\r\n    x = 1;\r\n    std::mem::replace(&mut x, 2);\r\n}\r\n```\r\n\r\n```\r\nwarning: value assigned to `x` is never read\r\n --> src/main.rs:2:9\r\n  |\r\n2 |     let x = 0;\r\n  |         ^\r\n  |\r\n  = note: #[warn(unused_assignments)] on by default\r\n\r\nerror[E0596]: cannot borrow immutable local variable `x` as mutable\r\n --> src/main.rs:4:28\r\n  |\r\n2 |     let x = 0;\r\n  |         - consider changing this to `mut x` <---- THIS NOTE\r\n3 |     x = 1;\r\n4 |     std::mem::replace(&mut x, 2);\r\n  |                            ^ cannot borrow mutably\r\n\r\nerror[E0384]: cannot assign twice to immutable variable `x`\r\n --> src/main.rs:3:5\r\n  |\r\n2 |     let x = 0;\r\n  |         - first assignment to `x`\r\n3 |     x = 1;\r\n  |     ^^^^^ cannot assign twice to immutable variable\r\n\r\nerror: aborting due to 2 previous errors\r\n```\r\n\r\nMIR borrowck should be doing this too.\r\n\r\nFIXME: I should write mentor notes"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/399196329","html_url":"https://github.com/rust-lang/rust/issues/46020#issuecomment-399196329","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/46020","id":399196329,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTE5NjMyOQ==","user":{"login":"nikomatsakis","id":155238,"node_id":"MDQ6VXNlcjE1NTIzOA==","avatar_url":"https://avatars0.githubusercontent.com/u/155238?v=4","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2018-06-21T18:15:23Z","updated_at":"2018-06-21T18:15:23Z","author_association":"CONTRIBUTOR","body":"Well, the AST version does too:\r\n\r\n```\r\nerror[E0596]: cannot borrow immutable local variable `x` as mutable\r\n --> src/main.rs:6:28\r\n  |\r\n4 |     let x = 0;\r\n  |         - consider changing this to `mut x`\r\n5 |     x = 1;\r\n6 |     std::mem::replace(&mut x, 2);\r\n  |                            ^ cannot borrow mutably\r\n\r\nerror[E0384]: cannot assign twice to immutable variable `x`\r\n --> src/main.rs:5:5\r\n  |\r\n4 |     let x = 0;\r\n  |         - first assignment to `x`\r\n5 |     x = 1;\r\n  |     ^^^^^ cannot assign twice to immutable variable\r\n```"}}
{"actor":{"display_login":"nikomatsakis"}}