{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/25507","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/25507/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/25507/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/25507/events","html_url":"https://github.com/rust-lang/rust/issues/25507","id":77152938,"number":25507,"title":"Unclear clear error message for borrowed contexts","user":{"login":"nwr","id":5010771,"avatar_url":"https://avatars.githubusercontent.com/u/5010771?v=3","gravatar_id":"","url":"https://api.github.com/users/nwr","html_url":"https://github.com/nwr","followers_url":"https://api.github.com/users/nwr/followers","following_url":"https://api.github.com/users/nwr/following{/other_user}","gists_url":"https://api.github.com/users/nwr/gists{/gist_id}","starred_url":"https://api.github.com/users/nwr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwr/subscriptions","organizations_url":"https://api.github.com/users/nwr/orgs","repos_url":"https://api.github.com/users/nwr/repos","events_url":"https://api.github.com/users/nwr/events{/privacy}","received_events_url":"https://api.github.com/users/nwr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-16T22:56:31Z","updated_at":"2015-05-17T15:06:16Z","closed_at":null,"body":"The error message for the following snippet could be improved, from IRC I was told to add `.iter()` onto line 7 (which worked). I believe a hint in the error message would be helpful.\r\n\r\n    struct MyStruct {\r\n        member : Vec<u8>,\r\n    }\r\n \r\n    impl MyStruct {\r\n        fn example (&self) {\r\n            for foo in self.member { // line 7\r\n                println!(\"{}\", foo);\r\n            }\r\n        }\r\n    }\r\n \r\n    fn main() {\r\n        let a = MyStruct { member : vec!(1, 2, 3) };\r\n        a.example();\r\n    }\r\n \r\nError seen:\r\n\r\n    src/main.rs:7:20: 7:24 error: cannot move out of borrowed content\r\n    src/main.rs:7         for foo in self.member {\r\n                                     ^~~~\r\n    note: in expansion of for loop expansion\r\n    src/main.rs:7:9: 9:10 note: expansion site\r\n    error: aborting due to previous error\r\n\r\nrustc --version --verbose:\r\n\r\n    rustc 1.1.0-nightly (e5394240a 2015-05-14) (built 2015-05-13)\r\n    binary: rustc\r\n    commit-hash: e5394240a295650b567aa406b4a0e1e3a6749a5f\r\n    commit-date: 2015-05-14\r\n    build-date: 2015-05-13\r\n    host: x86_64-apple-darwin\r\n    release: 1.1.0-nightly"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/102812829","html_url":"https://github.com/rust-lang/rust/issues/25507#issuecomment-102812829","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/25507","id":102812829,"user":{"login":"Stebalien","id":310393,"avatar_url":"https://avatars.githubusercontent.com/u/310393?v=3","gravatar_id":"","url":"https://api.github.com/users/Stebalien","html_url":"https://github.com/Stebalien","followers_url":"https://api.github.com/users/Stebalien/followers","following_url":"https://api.github.com/users/Stebalien/following{/other_user}","gists_url":"https://api.github.com/users/Stebalien/gists{/gist_id}","starred_url":"https://api.github.com/users/Stebalien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Stebalien/subscriptions","organizations_url":"https://api.github.com/users/Stebalien/orgs","repos_url":"https://api.github.com/users/Stebalien/repos","events_url":"https://api.github.com/users/Stebalien/events{/privacy}","received_events_url":"https://api.github.com/users/Stebalien/received_events","type":"User","site_admin":false},"created_at":"2015-05-17T15:06:16Z","updated_at":"2015-05-17T15:06:16Z","body":"This could definitely be improved. Just as an FYI, for loops take `IntoIterator`s by-value so the following also works:\r\n```rust\r\nfor foo in &self.member {\r\n    // ...\r\n}\r\n```\r\nThis is because `IntoIterator` is implemented on both `&Vec<T>` (producing an iterator that yields references to the items) and `Vec<T>` (producing an iterator that yields the items by value and consumes the vector.\r\n\r\nWe should probably add a detailed error message for this case; you're not the first to be confused."}}