Skip to content

Commit c2d6f8c

Browse files
committed
Check proc_macro on stmt
1 parent 3244d53 commit c2d6f8c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/librustc/hir/check_attr.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,11 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
269269
if attr.check_name("inline") {
270270
self.check_inline(attr, &stmt.span, Target::Statement);
271271
}
272-
if attr.check_name("repr") {
272+
if attr.check_name("repr")
273+
|| attr.check_name("proc_macro")
274+
|| attr.check_name("proc_macro_attribute")
275+
|| attr.check_name("proc_macro_derive")
276+
{
273277
self.emit_repr_error(
274278
attr.span,
275279
stmt.span,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 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+
#![feature(proc_macro)]
12+
13+
fn main() {
14+
#[proc_macro] //~ ERROR: attribute should not be applied to a statement
15+
let x = 10;
16+
#[proc_macro_attribute] //~ ERROR: attribute should not be applied to a statement
17+
let x = 11;
18+
#[proc_macro_derive] //~ ERROR: attribute should not be applied to a statement
19+
let x = 12;
20+
}

0 commit comments

Comments
 (0)