{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/35039654","id":35039654,"diff_hunk":"@@ -548,11 +546,17 @@ impl<'a> TraitDef<'a> {\n             let ty_param_names: Vec<ast::Name> = ty_params.iter()\n                 .map(|ty_param| ty_param.ident.name)\n                 .collect();\n+            let mut processed_types = HashSet::new();\n \n             for field_ty in field_tys {\n                 let tys = find_type_parameters(&*field_ty, &ty_param_names);\n \n                 for ty in tys {\n+                    // if we have already handled this type, skip it\n+                    if let ast::TyPath(_, ref p) = ty.node {\n+                        if processed_types.contains(&p.segments) { continue }","path":"src/libsyntax/ext/deriving/generic/mod.rs","position":30,"original_position":30,"commit_id":"3965952209e93f4d428622a9f405c5eb67ad37e8","original_commit_id":"3965952209e93f4d428622a9f405c5eb67ad37e8","user":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"body":"This can be `if !processed_types.insert(&p.segments) { continue }`.","created_at":"2015-07-20T20:27:09Z","updated_at":"2015-07-20T20:27:09Z","html_url":"https://github.com/rust-lang/rust/pull/27134#discussion_r35039654","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/27134","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/35039654"},"html":{"href":"https://github.com/rust-lang/rust/pull/27134#discussion_r35039654"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/27134"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/27134","id":40316592,"html_url":"https://github.com/rust-lang/rust/pull/27134","diff_url":"https://github.com/rust-lang/rust/pull/27134.diff","patch_url":"https://github.com/rust-lang/rust/pull/27134.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/27134","number":27134,"state":"open","locked":false,"title":"Avoid repeated trait bounds in derived impls","user":{"login":"fhartwig","id":83271,"avatar_url":"https://avatars.githubusercontent.com/u/83271?v=3","gravatar_id":"","url":"https://api.github.com/users/fhartwig","html_url":"https://github.com/fhartwig","followers_url":"https://api.github.com/users/fhartwig/followers","following_url":"https://api.github.com/users/fhartwig/following{/other_user}","gists_url":"https://api.github.com/users/fhartwig/gists{/gist_id}","starred_url":"https://api.github.com/users/fhartwig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhartwig/subscriptions","organizations_url":"https://api.github.com/users/fhartwig/orgs","repos_url":"https://api.github.com/users/fhartwig/repos","events_url":"https://api.github.com/users/fhartwig/events{/privacy}","received_events_url":"https://api.github.com/users/fhartwig/received_events","type":"User","site_admin":false},"body":"Fixes #25022\r\n\r\nThis adapts the deriving mechanism to not repeat bounds for the same type parameter. To give an example: for the following code:\r\n\r\n```rust\r\n#[derive(Clone)]\r\npub struct FlatMap<I, U: IntoIterator, F> {\r\n    iter: I,\r\n    f: F,\r\n    frontiter: Option<U::IntoIter>,\r\n    backiter: Option<U::IntoIter>,\r\n}\r\n```\r\nthe latest nightly generates the following impl signature:\r\n\r\n```rust\r\nimpl <I: ::std::clone::Clone,\r\n      U: ::std::clone::Clone + IntoIterator,\r\n      F: ::std::clone::Clone>\r\n::std::clone::Clone for FlatMap<I, U, F> where\r\n    I: ::std::clone::Clone,\r\n    F: ::std::clone::Clone,\r\n    U::IntoIter: ::std::clone::Clone,\r\n    U::IntoIter: ::std::clone::Clone\r\n```\r\n\r\nWith these changes, the signature changes to this:\r\n```rust\r\nimpl <I, U: IntoIterator, F> ::std::clone::Clone for FlatMap<I, U, F> where\r\n    I: ::std::clone::Clone,\r\n    F: ::std::clone::Clone,\r\n    U::IntoIter: ::std::clone::Clone\r\n```\r\n(Nothing in the body of the impl changes)\r\nNote that the second impl is more permissive, as it doesn't have a `Clone` bound on `U` at all. There was a compile-fail test that failed due to this. I don't understand why we would want the old behaviour (and nobody on IRC could tell me either), so please tell me if there is a good reason that I missed.","created_at":"2015-07-19T22:48:00Z","updated_at":"2015-07-20T20:27:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10e54d467c9d110020afd2aa20fd73b19f238800","assignee":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/27134/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/27134/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/27134/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/3965952209e93f4d428622a9f405c5eb67ad37e8","head":{"label":"fhartwig:derive","ref":"derive","sha":"3965952209e93f4d428622a9f405c5eb67ad37e8","user":{"login":"fhartwig","id":83271,"avatar_url":"https://avatars.githubusercontent.com/u/83271?v=3","gravatar_id":"","url":"https://api.github.com/users/fhartwig","html_url":"https://github.com/fhartwig","followers_url":"https://api.github.com/users/fhartwig/followers","following_url":"https://api.github.com/users/fhartwig/following{/other_user}","gists_url":"https://api.github.com/users/fhartwig/gists{/gist_id}","starred_url":"https://api.github.com/users/fhartwig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhartwig/subscriptions","organizations_url":"https://api.github.com/users/fhartwig/orgs","repos_url":"https://api.github.com/users/fhartwig/repos","events_url":"https://api.github.com/users/fhartwig/events{/privacy}","received_events_url":"https://api.github.com/users/fhartwig/received_events","type":"User","site_admin":false},"repo":{"id":31138182,"name":"rust","full_name":"fhartwig/rust","owner":{"login":"fhartwig","id":83271,"avatar_url":"https://avatars.githubusercontent.com/u/83271?v=3","gravatar_id":"","url":"https://api.github.com/users/fhartwig","html_url":"https://github.com/fhartwig","followers_url":"https://api.github.com/users/fhartwig/followers","following_url":"https://api.github.com/users/fhartwig/following{/other_user}","gists_url":"https://api.github.com/users/fhartwig/gists{/gist_id}","starred_url":"https://api.github.com/users/fhartwig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fhartwig/subscriptions","organizations_url":"https://api.github.com/users/fhartwig/orgs","repos_url":"https://api.github.com/users/fhartwig/repos","events_url":"https://api.github.com/users/fhartwig/events{/privacy}","received_events_url":"https://api.github.com/users/fhartwig/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fhartwig/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/fhartwig/rust","forks_url":"https://api.github.com/repos/fhartwig/rust/forks","keys_url":"https://api.github.com/repos/fhartwig/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fhartwig/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fhartwig/rust/teams","hooks_url":"https://api.github.com/repos/fhartwig/rust/hooks","issue_events_url":"https://api.github.com/repos/fhartwig/rust/issues/events{/number}","events_url":"https://api.github.com/repos/fhartwig/rust/events","assignees_url":"https://api.github.com/repos/fhartwig/rust/assignees{/user}","branches_url":"https://api.github.com/repos/fhartwig/rust/branches{/branch}","tags_url":"https://api.github.com/repos/fhartwig/rust/tags","blobs_url":"https://api.github.com/repos/fhartwig/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fhartwig/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fhartwig/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/fhartwig/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fhartwig/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/fhartwig/rust/languages","stargazers_url":"https://api.github.com/repos/fhartwig/rust/stargazers","contributors_url":"https://api.github.com/repos/fhartwig/rust/contributors","subscribers_url":"https://api.github.com/repos/fhartwig/rust/subscribers","subscription_url":"https://api.github.com/repos/fhartwig/rust/subscription","commits_url":"https://api.github.com/repos/fhartwig/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/fhartwig/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/fhartwig/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/fhartwig/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/fhartwig/rust/contents/{+path}","compare_url":"https://api.github.com/repos/fhartwig/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fhartwig/rust/merges","archive_url":"https://api.github.com/repos/fhartwig/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fhartwig/rust/downloads","issues_url":"https://api.github.com/repos/fhartwig/rust/issues{/number}","pulls_url":"https://api.github.com/repos/fhartwig/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/fhartwig/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/fhartwig/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fhartwig/rust/labels{/name}","releases_url":"https://api.github.com/repos/fhartwig/rust/releases{/id}","created_at":"2015-02-21T19:42:24Z","updated_at":"2015-05-01T13:50:41Z","pushed_at":"2015-07-19T22:18:15Z","git_url":"git://github.com/fhartwig/rust.git","ssh_url":"git@github.com:fhartwig/rust.git","clone_url":"https://github.com/fhartwig/rust.git","svn_url":"https://github.com/fhartwig/rust","homepage":"http://www.rust-lang.org","size":304614,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"a41178e8582001d7075d14699542e671c78badef","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","created_at":"2010-06-16T20:39:03Z","updated_at":"2015-07-20T17:21:58Z","pushed_at":"2015-07-20T20:20:13Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"http://www.rust-lang.org","size":647537,"stargazers_count":12674,"watchers_count":12674,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2438,"mirror_url":null,"open_issues_count":2160,"forks":2438,"open_issues":2160,"watchers":12674,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/27134"},"html":{"href":"https://github.com/rust-lang/rust/pull/27134"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/27134"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/27134/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/27134/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/27134/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/3965952209e93f4d428622a9f405c5eb67ad37e8"}}}}