Skip to content

Commit 73846dc

Browse files
authored
Rollup merge of rust-lang#49104 - csmoe:semicolon_error, r=petrochenkov
improve error message of inner attribute syntax Fixes rust-lang#49040
2 parents 63ab361 + 9f5a356 commit 73846dc

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/libsyntax/parse/attr.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a> Parser<'a> {
9090
debug!("parse_attribute_with_inner_parse_policy: inner_parse_policy={:?} self.token={:?}",
9191
inner_parse_policy,
9292
self.token);
93-
let (span, path, tokens, mut style) = match self.token {
93+
let (span, path, tokens, style) = match self.token {
9494
token::Pound => {
9595
let lo = self.span;
9696
self.bump();
@@ -129,15 +129,6 @@ impl<'a> Parser<'a> {
129129
}
130130
};
131131

132-
if inner_parse_policy == InnerAttributeParsePolicy::Permitted &&
133-
self.token == token::Semi {
134-
self.bump();
135-
self.span_warn(span,
136-
"this inner attribute syntax is deprecated. The new syntax is \
137-
`#![foo]`, with a bang and no semicolon");
138-
style = ast::AttrStyle::Inner;
139-
}
140-
141132
Ok(ast::Attribute {
142133
id: attr::mk_attr_id(),
143134
style,

src/test/ui/issue-49040.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![allow(unused_variables)]; //~ ERROR expected item, found `;`
12+
fn main() {}

src/test/ui/issue-49040.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected item, found `;`
2+
--> $DIR/issue-49040.rs:11:28
3+
|
4+
LL | #![allow(unused_variables)]; //~ ERROR expected item, found `;`
5+
| ^ help: consider removing this semicolon
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)