{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/21837","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/21837/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/21837/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/21837/events","html_url":"https://github.com/rust-lang/rust/issues/21837","id":56158822,"number":21837,"title":"Trait bounds on struct type parameters aren't always enforced (depending on the order of impls)","user":{"login":"SSheldon","id":478311,"avatar_url":"https://avatars.githubusercontent.com/u/478311?v=3","gravatar_id":"","url":"https://api.github.com/users/SSheldon","html_url":"https://github.com/SSheldon","followers_url":"https://api.github.com/users/SSheldon/followers","following_url":"https://api.github.com/users/SSheldon/following{/other_user}","gists_url":"https://api.github.com/users/SSheldon/gists{/gist_id}","starred_url":"https://api.github.com/users/SSheldon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SSheldon/subscriptions","organizations_url":"https://api.github.com/users/SSheldon/orgs","repos_url":"https://api.github.com/users/SSheldon/repos","events_url":"https://api.github.com/users/SSheldon/events{/privacy}","received_events_url":"https://api.github.com/users/SSheldon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/E-needstest","name":"E-needstest","color":"02e10c"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-medium","name":"P-medium","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2015-02-01T10:08:43Z","updated_at":"2015-10-29T11:54:52Z","closed_at":null,"body":"The following compiles without issue, even though the impl of `Trait2` is missing a trait bound that `T` implements `Bound`:\r\n``` rust\r\npub trait Bound { }\r\npub struct Foo<T: Bound>;\r\n\r\npub trait Trait1 { }\r\nimpl<T: Bound> Trait1 for Foo<T> { }\r\n\r\npub trait Trait2 { }\r\nimpl<T> Trait2 for Foo<T> { }\r\n\r\nfn main() { }\r\n```\r\n\r\nHowever, if you switch the order of the impls...\r\n``` rust\r\npub trait Bound { }\r\npub struct Foo<T: Bound>;\r\n\r\npub trait Trait2 { }\r\nimpl<T> Trait2 for Foo<T> { }\r\n\r\npub trait Trait1 { }\r\nimpl<T: Bound> Trait1 for Foo<T> { }\r\n\r\nfn main() { }\r\n```\r\n\r\nYou suddenly start getting this error:\r\n```\r\nerror: the trait `Bound` is not implemented for the type `T` [E0277]\r\nimpl<T> Trait2 for Foo<T> { }\r\n^~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nerror: aborting due to previous error\r\n```\r\n\r\nI did not expect the ordering of the impls to matter here. I'm using `rustc 1.0.0-nightly (1d00c545e 2015-01-30 19:56:34 +0000)`."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/152156699","html_url":"https://github.com/rust-lang/rust/issues/21837#issuecomment-152156699","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/21837","id":152156699,"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-10-29T11:54:52Z","updated_at":"2015-10-29T11:54:52Z","body":"Tagging as E-needstest, since we should be able to add a test with `WARN` messages (and perhaps a `#[rustc_error]` annotation on `main`)"}}