{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/27009","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/27009/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/27009/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/27009/events","html_url":"https://github.com/rust-lang/rust/issues/27009","id":94696571,"number":27009,"title":"Ownership error masks missing implementation of trait","user":{"login":"Leopard2A5","id":1137953,"avatar_url":"https://avatars.githubusercontent.com/u/1137953?v=3","gravatar_id":"","url":"https://api.github.com/users/Leopard2A5","html_url":"https://github.com/Leopard2A5","followers_url":"https://api.github.com/users/Leopard2A5/followers","following_url":"https://api.github.com/users/Leopard2A5/following{/other_user}","gists_url":"https://api.github.com/users/Leopard2A5/gists{/gist_id}","starred_url":"https://api.github.com/users/Leopard2A5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leopard2A5/subscriptions","organizations_url":"https://api.github.com/users/Leopard2A5/orgs","repos_url":"https://api.github.com/users/Leopard2A5/repos","events_url":"https://api.github.com/users/Leopard2A5/events{/privacy}","received_events_url":"https://api.github.com/users/Leopard2A5/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-13T11:12:01Z","updated_at":"2015-07-13T12:32:23Z","closed_at":null,"body":"I would expect the main function to not compile because clone() has not been implemented for struct Test. However this error is masked by:\r\n\r\n`src/main.rs:26:2: 26:7 error: cannot borrow `tests` as mutable because it is also borrowed as immutable`\r\n\r\nThe error here is the missing implementation though, because it solves the ownership issue. rustc doesn't complain about the missing implementation at all.\r\n\r\n    #[derive(Debug)]\r\n    struct Test {\r\n\t    name: String\r\n    }\r\n    \r\n    // impl std::clone::Clone for Test {\r\n    // \tfn clone(&self) -> Test {\r\n    // \t\tTest {\r\n    // \t\t\tname: self.name.clone()\r\n    // \t\t}\r\n    // \t}\r\n    // }\r\n    \r\n    fn main() {\r\n\t    let mut tests = Vec::new();\r\n\t    tests.push(Test{ name: \"test1\".to_string() });\r\n\t    tests.push(Test{ name: \"test2\".to_string() });\r\n\t    tests.push(Test{ name: \"test3\".to_string() });\r\n    \r\n\t    tests.sort_by(|a, b| a.name.cmp(&b.name));\r\n\t    println!(\"{:?}\", tests);\r\n    \r\n\t    let test = tests.last().unwrap().clone();\r\n\t    println!(\"{:?}\", test);\r\n    \r\n\t    tests.sort_by(|a, b| b.name.cmp(&a.name));\r\n        println!(\"{:?}\", tests);\r\n    }\r\n     "},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/120910952","html_url":"https://github.com/rust-lang/rust/issues/27009#issuecomment-120910952","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/27009","id":120910952,"user":{"login":"Leopard2A5","id":1137953,"avatar_url":"https://avatars.githubusercontent.com/u/1137953?v=3","gravatar_id":"","url":"https://api.github.com/users/Leopard2A5","html_url":"https://github.com/Leopard2A5","followers_url":"https://api.github.com/users/Leopard2A5/followers","following_url":"https://api.github.com/users/Leopard2A5/following{/other_user}","gists_url":"https://api.github.com/users/Leopard2A5/gists{/gist_id}","starred_url":"https://api.github.com/users/Leopard2A5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Leopard2A5/subscriptions","organizations_url":"https://api.github.com/users/Leopard2A5/orgs","repos_url":"https://api.github.com/users/Leopard2A5/repos","events_url":"https://api.github.com/users/Leopard2A5/events{/privacy}","received_events_url":"https://api.github.com/users/Leopard2A5/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T12:32:23Z","updated_at":"2015-07-13T12:32:23Z","body":"So to wrap it up it was my bad, because i didn't know that references can be cloned by default... kinda hard to put my finger on the actual problem here :P"}}