{"action":"created","comment":{"url":"https://api.github.com/repos/nrc/rustfmt/pulls/comments/41545573","id":41545573,"diff_hunk":"@@ -592,31 +592,88 @@ impl<'a> FmtVisitor<'a> {\n         self.buffer.push_str(&generics_str);\n \n         self.last_pos = body_start;\n-        self.block_indent = self.block_indent.block_indent(self.config);\n-        for (i, f) in enum_def.variants.iter().enumerate() {\n-            let next_span_start: BytePos = if i == enum_def.variants.len() - 1 {\n-                span.hi\n-            } else {\n-                enum_def.variants[i + 1].span.lo\n-            };\n \n-            self.visit_variant(f, i == enum_def.variants.len() - 1, next_span_start);\n+        // Need to preserve comments if no variants are present\n+        if enum_def.variants.is_empty() {\n+            self.format_missing_with_indent(span.hi - BytePos(1));\n+        } else {\n+            self.buffer.push_str(\"\\n\");\n+            let indentation = self.block_indent.block_indent(self.config).to_string(self.config);\n+\n+            self.buffer.push_str(&indentation);\n+            self.block_indent = self.block_indent.block_indent(self.config);\n+\n+            if let Some(body_str) = self.format_variant_list(enum_def,","path":"src/items.rs","position":23,"original_position":23,"commit_id":"59bfd943662d36b3cadeca98fb61d4679123a872","original_commit_id":"59bfd943662d36b3cadeca98fb61d4679123a872","user":{"login":"marcusklaas","id":1255413,"avatar_url":"https://avatars.githubusercontent.com/u/1255413?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusklaas","html_url":"https://github.com/marcusklaas","followers_url":"https://api.github.com/users/marcusklaas/followers","following_url":"https://api.github.com/users/marcusklaas/following{/other_user}","gists_url":"https://api.github.com/users/marcusklaas/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusklaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusklaas/subscriptions","organizations_url":"https://api.github.com/users/marcusklaas/orgs","repos_url":"https://api.github.com/users/marcusklaas/repos","events_url":"https://api.github.com/users/marcusklaas/events{/privacy}","received_events_url":"https://api.github.com/users/marcusklaas/received_events","type":"User","site_admin":false},"body":"Won't this produce an empty Enum body when `format_variant_list` returns `None`?","created_at":"2015-10-08T17:54:27Z","updated_at":"2015-10-08T17:54:27Z","html_url":"https://github.com/nrc/rustfmt/pull/420#discussion_r41545573","pull_request_url":"https://api.github.com/repos/nrc/rustfmt/pulls/420","_links":{"self":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/comments/41545573"},"html":{"href":"https://github.com/nrc/rustfmt/pull/420#discussion_r41545573"},"pull_request":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/420"}}},"pull_request":{"url":"https://api.github.com/repos/nrc/rustfmt/pulls/420","id":47096040,"html_url":"https://github.com/nrc/rustfmt/pull/420","diff_url":"https://github.com/nrc/rustfmt/pull/420.diff","patch_url":"https://github.com/nrc/rustfmt/pull/420.patch","issue_url":"https://api.github.com/repos/nrc/rustfmt/issues/420","number":420,"state":"open","locked":false,"title":"Fix https://github.com/nrc/rustfmt/issues/270","user":{"login":"mwiczer","id":9419335,"avatar_url":"https://avatars.githubusercontent.com/u/9419335?v=3","gravatar_id":"","url":"https://api.github.com/users/mwiczer","html_url":"https://github.com/mwiczer","followers_url":"https://api.github.com/users/mwiczer/followers","following_url":"https://api.github.com/users/mwiczer/following{/other_user}","gists_url":"https://api.github.com/users/mwiczer/gists{/gist_id}","starred_url":"https://api.github.com/users/mwiczer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwiczer/subscriptions","organizations_url":"https://api.github.com/users/mwiczer/orgs","repos_url":"https://api.github.com/users/mwiczer/repos","events_url":"https://api.github.com/users/mwiczer/events{/privacy}","received_events_url":"https://api.github.com/users/mwiczer/received_events","type":"User","site_admin":false},"body":"This is a re-post of PR #407 with only one commit (the original branch was f'ed beyond my rebase abilities).","created_at":"2015-10-07T23:35:36Z","updated_at":"2015-10-08T17:54:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f44284b5ea4370bd5418741c6a1a7dbfa8cec68","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nrc/rustfmt/pulls/420/commits","review_comments_url":"https://api.github.com/repos/nrc/rustfmt/pulls/420/comments","review_comment_url":"https://api.github.com/repos/nrc/rustfmt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nrc/rustfmt/issues/420/comments","statuses_url":"https://api.github.com/repos/nrc/rustfmt/statuses/59bfd943662d36b3cadeca98fb61d4679123a872","head":{"label":"mwiczer:Issue270","ref":"Issue270","sha":"59bfd943662d36b3cadeca98fb61d4679123a872","user":{"login":"mwiczer","id":9419335,"avatar_url":"https://avatars.githubusercontent.com/u/9419335?v=3","gravatar_id":"","url":"https://api.github.com/users/mwiczer","html_url":"https://github.com/mwiczer","followers_url":"https://api.github.com/users/mwiczer/followers","following_url":"https://api.github.com/users/mwiczer/following{/other_user}","gists_url":"https://api.github.com/users/mwiczer/gists{/gist_id}","starred_url":"https://api.github.com/users/mwiczer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwiczer/subscriptions","organizations_url":"https://api.github.com/users/mwiczer/orgs","repos_url":"https://api.github.com/users/mwiczer/repos","events_url":"https://api.github.com/users/mwiczer/events{/privacy}","received_events_url":"https://api.github.com/users/mwiczer/received_events","type":"User","site_admin":false},"repo":{"id":43395660,"name":"rustfmt","full_name":"mwiczer/rustfmt","owner":{"login":"mwiczer","id":9419335,"avatar_url":"https://avatars.githubusercontent.com/u/9419335?v=3","gravatar_id":"","url":"https://api.github.com/users/mwiczer","html_url":"https://github.com/mwiczer","followers_url":"https://api.github.com/users/mwiczer/followers","following_url":"https://api.github.com/users/mwiczer/following{/other_user}","gists_url":"https://api.github.com/users/mwiczer/gists{/gist_id}","starred_url":"https://api.github.com/users/mwiczer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwiczer/subscriptions","organizations_url":"https://api.github.com/users/mwiczer/orgs","repos_url":"https://api.github.com/users/mwiczer/repos","events_url":"https://api.github.com/users/mwiczer/events{/privacy}","received_events_url":"https://api.github.com/users/mwiczer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mwiczer/rustfmt","description":"Format Rust code","fork":true,"url":"https://api.github.com/repos/mwiczer/rustfmt","forks_url":"https://api.github.com/repos/mwiczer/rustfmt/forks","keys_url":"https://api.github.com/repos/mwiczer/rustfmt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mwiczer/rustfmt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mwiczer/rustfmt/teams","hooks_url":"https://api.github.com/repos/mwiczer/rustfmt/hooks","issue_events_url":"https://api.github.com/repos/mwiczer/rustfmt/issues/events{/number}","events_url":"https://api.github.com/repos/mwiczer/rustfmt/events","assignees_url":"https://api.github.com/repos/mwiczer/rustfmt/assignees{/user}","branches_url":"https://api.github.com/repos/mwiczer/rustfmt/branches{/branch}","tags_url":"https://api.github.com/repos/mwiczer/rustfmt/tags","blobs_url":"https://api.github.com/repos/mwiczer/rustfmt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mwiczer/rustfmt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mwiczer/rustfmt/git/refs{/sha}","trees_url":"https://api.github.com/repos/mwiczer/rustfmt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mwiczer/rustfmt/statuses/{sha}","languages_url":"https://api.github.com/repos/mwiczer/rustfmt/languages","stargazers_url":"https://api.github.com/repos/mwiczer/rustfmt/stargazers","contributors_url":"https://api.github.com/repos/mwiczer/rustfmt/contributors","subscribers_url":"https://api.github.com/repos/mwiczer/rustfmt/subscribers","subscription_url":"https://api.github.com/repos/mwiczer/rustfmt/subscription","commits_url":"https://api.github.com/repos/mwiczer/rustfmt/commits{/sha}","git_commits_url":"https://api.github.com/repos/mwiczer/rustfmt/git/commits{/sha}","comments_url":"https://api.github.com/repos/mwiczer/rustfmt/comments{/number}","issue_comment_url":"https://api.github.com/repos/mwiczer/rustfmt/issues/comments{/number}","contents_url":"https://api.github.com/repos/mwiczer/rustfmt/contents/{+path}","compare_url":"https://api.github.com/repos/mwiczer/rustfmt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mwiczer/rustfmt/merges","archive_url":"https://api.github.com/repos/mwiczer/rustfmt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mwiczer/rustfmt/downloads","issues_url":"https://api.github.com/repos/mwiczer/rustfmt/issues{/number}","pulls_url":"https://api.github.com/repos/mwiczer/rustfmt/pulls{/number}","milestones_url":"https://api.github.com/repos/mwiczer/rustfmt/milestones{/number}","notifications_url":"https://api.github.com/repos/mwiczer/rustfmt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mwiczer/rustfmt/labels{/name}","releases_url":"https://api.github.com/repos/mwiczer/rustfmt/releases{/id}","created_at":"2015-09-29T21:30:49Z","updated_at":"2015-09-29T21:30:50Z","pushed_at":"2015-10-07T23:26:16Z","git_url":"git://github.com/mwiczer/rustfmt.git","ssh_url":"git@github.com:mwiczer/rustfmt.git","clone_url":"https://github.com/mwiczer/rustfmt.git","svn_url":"https://github.com/mwiczer/rustfmt","homepage":null,"size":969,"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":"nrc:master","ref":"master","sha":"8880c0e5d3963c2ec75e22e70421d7185e746c7c","user":{"login":"nrc","id":762626,"avatar_url":"https://avatars.githubusercontent.com/u/762626?v=3","gravatar_id":"","url":"https://api.github.com/users/nrc","html_url":"https://github.com/nrc","followers_url":"https://api.github.com/users/nrc/followers","following_url":"https://api.github.com/users/nrc/following{/other_user}","gists_url":"https://api.github.com/users/nrc/gists{/gist_id}","starred_url":"https://api.github.com/users/nrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrc/subscriptions","organizations_url":"https://api.github.com/users/nrc/orgs","repos_url":"https://api.github.com/users/nrc/repos","events_url":"https://api.github.com/users/nrc/events{/privacy}","received_events_url":"https://api.github.com/users/nrc/received_events","type":"User","site_admin":false},"repo":{"id":31830551,"name":"rustfmt","full_name":"nrc/rustfmt","owner":{"login":"nrc","id":762626,"avatar_url":"https://avatars.githubusercontent.com/u/762626?v=3","gravatar_id":"","url":"https://api.github.com/users/nrc","html_url":"https://github.com/nrc","followers_url":"https://api.github.com/users/nrc/followers","following_url":"https://api.github.com/users/nrc/following{/other_user}","gists_url":"https://api.github.com/users/nrc/gists{/gist_id}","starred_url":"https://api.github.com/users/nrc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrc/subscriptions","organizations_url":"https://api.github.com/users/nrc/orgs","repos_url":"https://api.github.com/users/nrc/repos","events_url":"https://api.github.com/users/nrc/events{/privacy}","received_events_url":"https://api.github.com/users/nrc/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nrc/rustfmt","description":"Format Rust code","fork":false,"url":"https://api.github.com/repos/nrc/rustfmt","forks_url":"https://api.github.com/repos/nrc/rustfmt/forks","keys_url":"https://api.github.com/repos/nrc/rustfmt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nrc/rustfmt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nrc/rustfmt/teams","hooks_url":"https://api.github.com/repos/nrc/rustfmt/hooks","issue_events_url":"https://api.github.com/repos/nrc/rustfmt/issues/events{/number}","events_url":"https://api.github.com/repos/nrc/rustfmt/events","assignees_url":"https://api.github.com/repos/nrc/rustfmt/assignees{/user}","branches_url":"https://api.github.com/repos/nrc/rustfmt/branches{/branch}","tags_url":"https://api.github.com/repos/nrc/rustfmt/tags","blobs_url":"https://api.github.com/repos/nrc/rustfmt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nrc/rustfmt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nrc/rustfmt/git/refs{/sha}","trees_url":"https://api.github.com/repos/nrc/rustfmt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nrc/rustfmt/statuses/{sha}","languages_url":"https://api.github.com/repos/nrc/rustfmt/languages","stargazers_url":"https://api.github.com/repos/nrc/rustfmt/stargazers","contributors_url":"https://api.github.com/repos/nrc/rustfmt/contributors","subscribers_url":"https://api.github.com/repos/nrc/rustfmt/subscribers","subscription_url":"https://api.github.com/repos/nrc/rustfmt/subscription","commits_url":"https://api.github.com/repos/nrc/rustfmt/commits{/sha}","git_commits_url":"https://api.github.com/repos/nrc/rustfmt/git/commits{/sha}","comments_url":"https://api.github.com/repos/nrc/rustfmt/comments{/number}","issue_comment_url":"https://api.github.com/repos/nrc/rustfmt/issues/comments{/number}","contents_url":"https://api.github.com/repos/nrc/rustfmt/contents/{+path}","compare_url":"https://api.github.com/repos/nrc/rustfmt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nrc/rustfmt/merges","archive_url":"https://api.github.com/repos/nrc/rustfmt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nrc/rustfmt/downloads","issues_url":"https://api.github.com/repos/nrc/rustfmt/issues{/number}","pulls_url":"https://api.github.com/repos/nrc/rustfmt/pulls{/number}","milestones_url":"https://api.github.com/repos/nrc/rustfmt/milestones{/number}","notifications_url":"https://api.github.com/repos/nrc/rustfmt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nrc/rustfmt/labels{/name}","releases_url":"https://api.github.com/repos/nrc/rustfmt/releases{/id}","created_at":"2015-03-07T22:51:56Z","updated_at":"2015-10-08T17:47:58Z","pushed_at":"2015-10-08T17:51:35Z","git_url":"git://github.com/nrc/rustfmt.git","ssh_url":"git@github.com:nrc/rustfmt.git","clone_url":"https://github.com/nrc/rustfmt.git","svn_url":"https://github.com/nrc/rustfmt","homepage":null,"size":2102,"stargazers_count":388,"watchers_count":388,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":62,"mirror_url":null,"open_issues_count":104,"forks":62,"open_issues":104,"watchers":388,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/420"},"html":{"href":"https://github.com/nrc/rustfmt/pull/420"},"issue":{"href":"https://api.github.com/repos/nrc/rustfmt/issues/420"},"comments":{"href":"https://api.github.com/repos/nrc/rustfmt/issues/420/comments"},"review_comments":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/420/comments"},"review_comment":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nrc/rustfmt/pulls/420/commits"},"statuses":{"href":"https://api.github.com/repos/nrc/rustfmt/statuses/59bfd943662d36b3cadeca98fb61d4679123a872"}}}}