{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/24085","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/24085/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/24085/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/24085/events","html_url":"https://github.com/rust-lang/rust/issues/24085","id":66388139,"number":24085,"title":"Adding Copy impl to type causes lifetime errors","user":{"login":"bkoropoff","id":2101303,"avatar_url":"https://avatars.githubusercontent.com/u/2101303?v=3","gravatar_id":"","url":"https://api.github.com/users/bkoropoff","html_url":"https://github.com/bkoropoff","followers_url":"https://api.github.com/users/bkoropoff/followers","following_url":"https://api.github.com/users/bkoropoff/following{/other_user}","gists_url":"https://api.github.com/users/bkoropoff/gists{/gist_id}","starred_url":"https://api.github.com/users/bkoropoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bkoropoff/subscriptions","organizations_url":"https://api.github.com/users/bkoropoff/orgs","repos_url":"https://api.github.com/users/bkoropoff/repos","events_url":"https://api.github.com/users/bkoropoff/events{/privacy}","received_events_url":"https://api.github.com/users/bkoropoff/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-lifetimes","name":"A-lifetimes","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-04-05T01:33:05Z","updated_at":"2015-04-13T16:32:04Z","closed_at":null,"body":"# Code #\r\n\r\n[Playpen link](http://is.gd/m7xK5R)\r\n\r\n```rust\r\n#[derive(Clone)]\r\n// Uncommenting the next line causes an error\r\n//#[derive(Copy)]\r\nstruct Path<'a:'b, 'b> {\r\n    x: &'a i32,\r\n    tail: Option<&'b Path<'a, 'b>>\r\n}\r\n\r\n#[allow(dead_code, unconditional_recursion)]\r\nfn foo<'a,'b,F>(p: Path<'a, 'b>, mut f: F)\r\n                where F: for<'c> FnMut(Path<'a, 'c>) {\r\n    foo(p, |x| f(x))\r\n}\r\n```\r\n\r\n# Error #\r\n\r\n```\r\n<anon>:12:5: 12:8 error: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements\r\n<anon>:12     foo(p, |x| f(x))\r\n              ^~~\r\n<anon>:12:16: 12:20 note: first, the lifetime cannot outlive the lifetime 'c as defined on the block at 12:15...\r\n<anon>:12     foo(p, |x| f(x))\r\n                         ^~~~\r\n<anon>:12:13: 12:14 note: ...so that trait type parameters matches those specified on the impl (expected `core::marker::Copy`, found `core::marker::Copy`)\r\n<anon>:12     foo(p, |x| f(x))\r\n                      ^\r\n<anon>:11:54: 13:2 note: but, the lifetime must be valid for the lifetime 'a as defined on the block at 11:53...\r\n<anon>:11                 where F: for<'c> FnMut(Path<'a, 'c>) {\r\n<anon>:12     foo(p, |x| f(x))\r\n<anon>:13 }\r\n<anon>:12:5: 12:8 note: ...so that trait type parameters matches those specified on the impl (expected `core::ops::FnOnce<(Path<'_, 'c>,)>`, found `for<'c> core::ops::FnOnce<(Path<'a, 'c>,)>`)\r\n<anon>:12     foo(p, |x| f(x))\r\n              ^~~\r\n```\r\n\r\n# Analysis #\r\n\r\nNotably, this does not occur with a trait like:\r\n\r\n```rust\r\ntrait FakeCopy where Self: Clone {}\r\n```\r\n\r\nThis smells like a bug to me, unless a language change introduced special treatment of `Copy` with regard to lifetimes.\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/92418963","html_url":"https://github.com/rust-lang/rust/issues/24085#issuecomment-92418963","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/24085","id":92418963,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","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":"2015-04-13T16:32:04Z","updated_at":"2015-04-13T16:32:04Z","body":"@bkoropoff hmm good catch, sorry I let this slip through last week :( I'll try to pay it some attention now. The current code does not seem entirely wrong to me, though. I have to think this through a bit."}}