{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/70512347","id":70512347,"diff_hunk":"@@ -55,26 +76,48 @@ impl<'a> Parser<'a> {\n     /// If permit_inner is true, then a leading `!` indicates an inner\n     /// attribute\n     pub fn parse_attribute(&mut self, permit_inner: bool) -> PResult<'a, ast::Attribute> {\n-        debug!(\"parse_attributes: permit_inner={:?} self.token={:?}\",\n+        debug!(\"parse_attribute: permit_inner={:?} self.token={:?}\",\n                permit_inner,\n                self.token);\n+        let inner_parse_policy = if permit_inner {\n+            InnerAttributeParsePolicy::Permitted\n+        } else {\n+            InnerAttributeParsePolicy::NotPermitted\n+                { reason: DEFAULT_UNEXPECTED_INNER_ATTR_ERR_MSG }\n+        };\n+        self.parse_attribute_with_inner_parse_policy(inner_parse_policy)\n+    }\n+\n+    /// The same as `parse_attribute`, except it takes in an `InnerAttributeParsePolicy`\n+    /// that prescribes how to handle inner attributes.\n+    fn parse_attribute_with_inner_parse_policy(&mut self,\n+                                               inner_parse_policy: InnerAttributeParsePolicy)\n+                                               -> PResult<'a, ast::Attribute> {\n+        debug!(\"parse_attribute_with_inner_parse_policy: inner_parse_policy={:?} self.token={:?}\",\n+               inner_parse_policy,\n+               self.token);\n         let (span, value, mut style) = match self.token {\n             token::Pound => {\n                 let lo = self.span.lo;\n                 self.bump();\n \n-                if permit_inner {\n+                if inner_parse_policy == InnerAttributeParsePolicy::Permitted {\n                     self.expected_tokens.push(TokenType::Token(token::Not));\n                 }\n                 let style = if self.token == token::Not {\n                     self.bump();\n-                    if !permit_inner {\n+                    if let InnerAttributeParsePolicy::NotPermitted { reason } = inner_parse_policy\n+                    {\n                         let span = self.span;\n                         self.diagnostic()\n-                            .struct_span_err(span,\n-                                             \"an inner attribute is not permitted in this context\")\n+                            .struct_span_err(span, reason)\n                             .help(\"place inner attribute at the top of the module or \\\n                                    block\")\n+                            .note(\"inner attributes and doc comments, like `#![no_std]` or \\\n+                                   `//! My crate`, annotate the item enclosing them, and are \\\n+                                   usually found at the crate root. Outer attributes and doc \\","path":"src/libsyntax/parse/attr.rs","position":106,"original_position":106,"commit_id":"976bbe437870ab2794f0ab6f163adf674b64f3c3","original_commit_id":"976bbe437870ab2794f0ab6f163adf674b64f3c3","user":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"body":"Agreed. @aravind-pg can you make one more update?\r\n\r\nI also strongly feel that the help is redundant now. Help says 'place inner attribute at X'; note says 'inner attributes annotate the item enclosing them'. The two statements are semantically similar. If there is important information missing from the note then the wording can be tweaked slightly. I'd like to remove the note.","created_at":"2016-07-12T20:09:38Z","updated_at":"2016-07-12T20:09:38Z","html_url":"https://github.com/rust-lang/rust/pull/34676#discussion_r70512347","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/34676","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/70512347"},"html":{"href":"https://github.com/rust-lang/rust/pull/34676#discussion_r70512347"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34676"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/34676","id":76378431,"html_url":"https://github.com/rust-lang/rust/pull/34676","diff_url":"https://github.com/rust-lang/rust/pull/34676.diff","patch_url":"https://github.com/rust-lang/rust/pull/34676.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34676","number":34676,"state":"open","locked":false,"title":"Better error message for inner attribute following doc comment","user":{"login":"aravind-pg","id":6913107,"avatar_url":"https://avatars.githubusercontent.com/u/6913107?v=3","gravatar_id":"","url":"https://api.github.com/users/aravind-pg","html_url":"https://github.com/aravind-pg","followers_url":"https://api.github.com/users/aravind-pg/followers","following_url":"https://api.github.com/users/aravind-pg/following{/other_user}","gists_url":"https://api.github.com/users/aravind-pg/gists{/gist_id}","starred_url":"https://api.github.com/users/aravind-pg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aravind-pg/subscriptions","organizations_url":"https://api.github.com/users/aravind-pg/orgs","repos_url":"https://api.github.com/users/aravind-pg/repos","events_url":"https://api.github.com/users/aravind-pg/events{/privacy}","received_events_url":"https://api.github.com/users/aravind-pg/received_events","type":"User","site_admin":false},"body":"Before it was always just \"an inner attribute is not permitted in this context\", whereas now we add a special case for when an inner attr follows an outer attr. If the outer attr is a doc comment, then the error is \"an inner attr is not permitted following a doc comment\", and otherwise it's \"an inner attr is not permitted following an outer attribute\". In all other cases it's still  \"an inner attribute is not permitted in this context\". \r\n\r\nNote that the public API and behaviour of `parse_attribute` is unchanged. Also, all new names are very open to bikeshedding -- they're arguably clunky.\r\n\r\nFixes #34516. cc @brson ","created_at":"2016-07-06T04:48:32Z","updated_at":"2016-07-12T20:09:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5eaea152a375ec11dd5cd24e8cec7d4c54c608a2","assignee":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"assignees":[{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/34676/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/34676/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/34676/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/976bbe437870ab2794f0ab6f163adf674b64f3c3","head":{"label":"aravind-pg:inner-attr","ref":"inner-attr","sha":"976bbe437870ab2794f0ab6f163adf674b64f3c3","user":{"login":"aravind-pg","id":6913107,"avatar_url":"https://avatars.githubusercontent.com/u/6913107?v=3","gravatar_id":"","url":"https://api.github.com/users/aravind-pg","html_url":"https://github.com/aravind-pg","followers_url":"https://api.github.com/users/aravind-pg/followers","following_url":"https://api.github.com/users/aravind-pg/following{/other_user}","gists_url":"https://api.github.com/users/aravind-pg/gists{/gist_id}","starred_url":"https://api.github.com/users/aravind-pg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aravind-pg/subscriptions","organizations_url":"https://api.github.com/users/aravind-pg/orgs","repos_url":"https://api.github.com/users/aravind-pg/repos","events_url":"https://api.github.com/users/aravind-pg/events{/privacy}","received_events_url":"https://api.github.com/users/aravind-pg/received_events","type":"User","site_admin":false},"repo":{"id":62596721,"name":"rust","full_name":"aravind-pg/rust","owner":{"login":"aravind-pg","id":6913107,"avatar_url":"https://avatars.githubusercontent.com/u/6913107?v=3","gravatar_id":"","url":"https://api.github.com/users/aravind-pg","html_url":"https://github.com/aravind-pg","followers_url":"https://api.github.com/users/aravind-pg/followers","following_url":"https://api.github.com/users/aravind-pg/following{/other_user}","gists_url":"https://api.github.com/users/aravind-pg/gists{/gist_id}","starred_url":"https://api.github.com/users/aravind-pg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aravind-pg/subscriptions","organizations_url":"https://api.github.com/users/aravind-pg/orgs","repos_url":"https://api.github.com/users/aravind-pg/repos","events_url":"https://api.github.com/users/aravind-pg/events{/privacy}","received_events_url":"https://api.github.com/users/aravind-pg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aravind-pg/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/aravind-pg/rust","forks_url":"https://api.github.com/repos/aravind-pg/rust/forks","keys_url":"https://api.github.com/repos/aravind-pg/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aravind-pg/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aravind-pg/rust/teams","hooks_url":"https://api.github.com/repos/aravind-pg/rust/hooks","issue_events_url":"https://api.github.com/repos/aravind-pg/rust/issues/events{/number}","events_url":"https://api.github.com/repos/aravind-pg/rust/events","assignees_url":"https://api.github.com/repos/aravind-pg/rust/assignees{/user}","branches_url":"https://api.github.com/repos/aravind-pg/rust/branches{/branch}","tags_url":"https://api.github.com/repos/aravind-pg/rust/tags","blobs_url":"https://api.github.com/repos/aravind-pg/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aravind-pg/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aravind-pg/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/aravind-pg/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aravind-pg/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/aravind-pg/rust/languages","stargazers_url":"https://api.github.com/repos/aravind-pg/rust/stargazers","contributors_url":"https://api.github.com/repos/aravind-pg/rust/contributors","subscribers_url":"https://api.github.com/repos/aravind-pg/rust/subscribers","subscription_url":"https://api.github.com/repos/aravind-pg/rust/subscription","commits_url":"https://api.github.com/repos/aravind-pg/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/aravind-pg/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/aravind-pg/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/aravind-pg/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/aravind-pg/rust/contents/{+path}","compare_url":"https://api.github.com/repos/aravind-pg/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aravind-pg/rust/merges","archive_url":"https://api.github.com/repos/aravind-pg/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aravind-pg/rust/downloads","issues_url":"https://api.github.com/repos/aravind-pg/rust/issues{/number}","pulls_url":"https://api.github.com/repos/aravind-pg/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/aravind-pg/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/aravind-pg/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aravind-pg/rust/labels{/name}","releases_url":"https://api.github.com/repos/aravind-pg/rust/releases{/id}","deployments_url":"https://api.github.com/repos/aravind-pg/rust/deployments","created_at":"2016-07-05T01:25:18Z","updated_at":"2016-07-05T01:25:37Z","pushed_at":"2016-07-12T15:05:28Z","git_url":"git://github.com/aravind-pg/rust.git","ssh_url":"git@github.com:aravind-pg/rust.git","clone_url":"https://github.com/aravind-pg/rust.git","svn_url":"https://github.com/aravind-pg/rust","homepage":"https://www.rust-lang.org","size":297814,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"31e9ed5d6cf567557d2219add7afedae93aaf2a5","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}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2016-07-12T20:01:58Z","pushed_at":"2016-07-12T19:51:19Z","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":"https://www.rust-lang.org","size":516479,"stargazers_count":17442,"watchers_count":17442,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3333,"mirror_url":null,"open_issues_count":2583,"forks":3333,"open_issues":2583,"watchers":17442,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34676"},"html":{"href":"https://github.com/rust-lang/rust/pull/34676"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/34676"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/34676/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34676/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/34676/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/976bbe437870ab2794f0ab6f163adf674b64f3c3"}}}}
{"actor":{"display_login":"brson"}}