Skip to content

Commit 9f5a356

Browse files
committed
improve attribute trailing semicolon error
1 parent a7170b0 commit 9f5a356

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/libsyntax/parse/attr.rs

+1-10
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

+12
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

+8
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)