{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/22019","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/22019/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/22019/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/22019/events","html_url":"https://github.com/rust-lang/rust/issues/22019","id":56862427,"number":22019,"title":"Cache failure when environment contains predicates with free lifetimes","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-06T20:18:06Z","updated_at":"2015-02-06T20:18:06Z","closed_at":null,"body":"The following example fails to compile in a nonsense way:\r\n\r\n```rust\r\n#![allow(missing_copy_implementations)]\r\n#![allow(unused_variables)]\r\n\r\nuse std::borrow::ToOwned;\r\n\r\npub struct CFGNode;\r\n\r\npub type Node<'a> = &'a CFGNode;\r\n\r\npub trait GraphWalk<'c, N> {\r\n    /// Returns all the nodes in this graph.\r\n    fn nodes(&'c self) where [N]:ToOwned<Vec<N>>;\r\n}\r\n\r\nimpl<'g> GraphWalk<'g, Node<'g>> for u32\r\n{\r\n    fn nodes(&'g self) where [Node<'g>]:ToOwned<Vec<Node<'g>>>\r\n    { loop { } }\r\n}\r\n\r\nimpl<'h> GraphWalk<'h, Node<'h>> for u64\r\n{\r\n    fn nodes(&'h self) where [Node<'h>]:ToOwned<Vec<Node<'h>>>\r\n    { loop { } }\r\n}\r\n\r\nfn main()  { }\r\n```\r\n\r\n[Running this code](http://is.gd/9bRg32) yields the following errors:\r\n\r\n```\r\n\r\n\r\n<anon>:23:5: 24:17 error: mismatched types:\r\n expected `core::borrow::ToOwned<collections::vec::Vec<&'h CFGNode>>`,\r\n    found `core::borrow::ToOwned<collections::vec::Vec<&'g CFGNode>>`\r\n(lifetime mismatch) [E0308]\r\n<anon>:23     fn nodes(&'h self) where [Node<'h>]:ToOwned<Vec<Node<'h>>>\r\n<anon>:24     { loop { } }\r\n<anon>:24:5: 24:17 note: the lifetime 'h as defined on the block at 24:4...\r\n<anon>:24     { loop { } }\r\n              ^~~~~~~~~~~~\r\n<anon>:18:5: 18:17 note: ...does not necessarily outlive the lifetime 'g as defined on the block at 18:4\r\n<anon>:18     { loop { } }\r\n              ^~~~~~~~~~~~\r\n<anon>:23:5: 24:17 error: mismatched types:\r\n expected `core::borrow::ToOwned<collections::vec::Vec<&'h CFGNode>>`,\r\n    found `core::borrow::ToOwned<collections::vec::Vec<&'g CFGNode>>`\r\n(lifetime mismatch) [E0308]\r\n<anon>:23     fn nodes(&'h self) where [Node<'h>]:ToOwned<Vec<Node<'h>>>\r\n<anon>:24     { loop { } }\r\n<anon>:18:5: 18:17 note: the lifetime 'g as defined on the block at 18:4...\r\n<anon>:18     { loop { } }\r\n              ^~~~~~~~~~~~\r\n<anon>:24:5: 24:17 note: ...does not necessarily outlive the lifetime 'h as defined on the block at 24:4\r\n<anon>:24     { loop { } }\r\n              ^~~~~~~~~~~~\r\nerror: aborting due to 2 previous errors\r\nplaypen: application terminated with error code 101\r\nProgram ended.\r\n```\r\n\r\nThese are nonsense because you can see the compiler is comparing two lifetimes (`'g` and `'h`) that are never simultaneously in scope. This arises due to errors in caching."}}