{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/20671","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/20671/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/20671/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/20671/events","html_url":"https://github.com/rust-lang/rust/issues/20671","id":53582955,"number":20671,"title":"where clauses for super traits do not fully propagate","user":{"login":"aturon","id":709807,"avatar_url":"https://avatars.githubusercontent.com/u/709807?v=3","gravatar_id":"","url":"https://api.github.com/users/aturon","html_url":"https://github.com/aturon","followers_url":"https://api.github.com/users/aturon/followers","following_url":"https://api.github.com/users/aturon/following{/other_user}","gists_url":"https://api.github.com/users/aturon/gists{/gist_id}","starred_url":"https://api.github.com/users/aturon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aturon/subscriptions","organizations_url":"https://api.github.com/users/aturon/orgs","repos_url":"https://api.github.com/users/aturon/repos","events_url":"https://api.github.com/users/aturon/events{/privacy}","received_events_url":"https://api.github.com/users/aturon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-07T00:38:59Z","updated_at":"2015-01-07T09:43:30Z","closed_at":null,"body":"The following example:\r\n\r\n```rust\r\ntrait Foo<T> {\r\n   fn foo(&self) -> &T;\r\n}\r\n \r\ntrait Bar<A> where A: Foo<Self> {}\r\n \r\nfn foobar<A, B: Bar<A>>(a: &A) -> &B {\r\n   a.foo()\r\n}\r\n```\r\n\r\nfails with \"error: type `&A` does not implement any method in scope named `foo`\".\r\n\r\nThis UFCS variant\r\n\r\n```rust\r\ntrait Foo<T> {\r\n    fn foo(&self) -> &T;\r\n}\r\n\r\ntrait Bar<A> where A: Foo<Self> {}\r\n\r\nfn foobar<A, B: Bar<A>>(a: &A) -> &B {\r\n    Foo::foo(a)\r\n}\r\n```\r\n\r\nfails with \"error: the trait `Foo<_>` is not implemented for the type `A`\"."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/68999057","html_url":"https://github.com/rust-lang/rust/issues/20671#issuecomment-68999057","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/20671","id":68999057,"user":{"login":"jroesch","id":696509,"avatar_url":"https://avatars.githubusercontent.com/u/696509?v=3","gravatar_id":"","url":"https://api.github.com/users/jroesch","html_url":"https://github.com/jroesch","followers_url":"https://api.github.com/users/jroesch/followers","following_url":"https://api.github.com/users/jroesch/following{/other_user}","gists_url":"https://api.github.com/users/jroesch/gists{/gist_id}","starred_url":"https://api.github.com/users/jroesch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jroesch/subscriptions","organizations_url":"https://api.github.com/users/jroesch/orgs","repos_url":"https://api.github.com/users/jroesch/repos","events_url":"https://api.github.com/users/jroesch/events{/privacy}","received_events_url":"https://api.github.com/users/jroesch/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T09:43:29Z","updated_at":"2015-01-07T09:43:29Z","body":"@japaric It is also my understanding (from conversations with @nikomatsakis) that this should work. It seems related to the generalization of bounds checking. \r\n\r\nOne of the annoyances I started purging from the compiler is the `ParamBounds` struct which is still used to store the super traits bounds declared on a trait definition. This is one of (if not the last) place where we still have special treatment of bounds (modulo my open PR). It is my hunch that the bounds checking code introduces all super trait bounds but doesn't do anything with the ones declared in the where clause. \r\n\r\nI think this is an important question to resolve generally because like @aturon it was my understanding that any super trait bound should be identical to bounding the `Self` type with the same bound. I believe Niko and I had talked about needing to make some more reaching changes to support this, and if I recall correctly it was around the computing of super trait bounds. \r\n\r\nIn my imagined scheme we should probably collect any Self type constraints and introduce them like we have been with super trait bounds. It seems to me this would be the simplest strategy, and avoids introducing a breaking change for anyone relying on the current behavior (esp. if this isn't resolved pre-1.0)."}}