{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/18651","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/18651/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/18651/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/18651/events","html_url":"https://github.com/rust-lang/rust/issues/18651","id":47824711,"number":18651,"title":"Attempting to clone Vec<T> for non-cloneable T returns &[T]","user":{"login":"hannobraun","id":85732,"avatar_url":"https://avatars.githubusercontent.com/u/85732?v=3","gravatar_id":"","url":"https://api.github.com/users/hannobraun","html_url":"https://github.com/hannobraun","followers_url":"https://api.github.com/users/hannobraun/followers","following_url":"https://api.github.com/users/hannobraun/following{/other_user}","gists_url":"https://api.github.com/users/hannobraun/gists{/gist_id}","starred_url":"https://api.github.com/users/hannobraun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannobraun/subscriptions","organizations_url":"https://api.github.com/users/hannobraun/orgs","repos_url":"https://api.github.com/users/hannobraun/repos","events_url":"https://api.github.com/users/hannobraun/events{/privacy}","received_events_url":"https://api.github.com/users/hannobraun/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-diagnostics","name":"A-diagnostics","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2014-11-05T11:14:20Z","updated_at":"2016-04-24T21:15:28Z","closed_at":null,"body":"This code works as expected:\r\n``` Rust\r\n#[deriving(Clone)]\r\nstruct MyStruct;\r\n\r\nfn main() {\r\n\tlet v1: Vec<MyStruct> = Vec::new();\r\n\tlet v2: Vec<MyStruct> = v1.clone();\r\n}\r\n```\r\n\r\nSomething odd happens when I remove `#[deriving(Clone)]`:\r\n``` Rust\r\nstruct MyStruct;\r\n\r\nfn main() {\r\n\tlet v1: Vec<MyStruct> = Vec::new();\r\n\tlet v2: Vec<MyStruct> = v1.clone();\r\n}\r\n```\r\n\r\nI would expect an error message about `MyStruct` not implementing `Clone`. Instead I get this error:\r\n```\r\nmain.rs:5:26: 5:36 error: mismatched types: expected `collections::vec::Vec<MyStruct>`, found `&[MyStruct]` (expected struct collections::vec::Vec, found &-ptr)\r\nmain.rs:5 \tlet v2: Vec<MyStruct> = v1.clone();\r\n          \t                        ^~~~~~~~~~\r\nerror: aborting due to previous error\r\n```\r\n\r\nThis works again:\r\n``` Rust\r\nstruct MyStruct;\r\n\r\nfn main() {\r\n\tlet v1: Vec<MyStruct> = Vec::new();\r\n\tlet v2: &[MyStruct] = v1.clone();\r\n}\r\n```\r\n\r\nAm I missing something here? Since `Vec::clone` is only implemented for `T: Clone`, it shouldn't be possible to call `clone` at all. Why would it return a `&[T]`?"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/214038365","html_url":"https://github.com/rust-lang/rust/issues/18651#issuecomment-214038365","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/18651","id":214038365,"user":{"login":"jooert","id":1774713,"avatar_url":"https://avatars.githubusercontent.com/u/1774713?v=3","gravatar_id":"","url":"https://api.github.com/users/jooert","html_url":"https://github.com/jooert","followers_url":"https://api.github.com/users/jooert/followers","following_url":"https://api.github.com/users/jooert/following{/other_user}","gists_url":"https://api.github.com/users/jooert/gists{/gist_id}","starred_url":"https://api.github.com/users/jooert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jooert/subscriptions","organizations_url":"https://api.github.com/users/jooert/orgs","repos_url":"https://api.github.com/users/jooert/repos","events_url":"https://api.github.com/users/jooert/events{/privacy}","received_events_url":"https://api.github.com/users/jooert/received_events","type":"User","site_admin":false},"created_at":"2016-04-24T21:15:28Z","updated_at":"2016-04-24T21:15:28Z","body":"Triage: As I understand this, the original error has been fixed and so this can be closed, right?"}}