]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / compile-fail-fulldeps / proc-macro / proc-macro-gates.rs
CommitLineData
83c7162d
XL
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// aux-build:proc-macro-gates.rs
0bf4aa26 12// gate-test-proc_macro_hygiene
83c7162d 13
b7449926 14#![feature(stmt_expr_attributes)]
83c7162d
XL
15
16extern crate proc_macro_gates as foo;
17
18use foo::*;
19
83c7162d 20fn _test_inner() {
b7449926 21 #![a] //~ ERROR: non-builtin inner attributes are unstable
83c7162d
XL
22}
23
24#[a] //~ ERROR: custom attributes cannot be applied to modules
25mod _test2 {}
26
27mod _test2_inner {
28 #![a] //~ ERROR: custom attributes cannot be applied to modules
b7449926 29 //~| ERROR: non-builtin inner attributes are unstable
83c7162d
XL
30}
31
32#[a = y] //~ ERROR: must only be followed by a delimiter token
33fn _test3() {}
34
83c7162d
XL
35fn attrs() {
36 // Statement, item
37 #[a] // OK
38 struct S;
39
40 // Statement, macro
41 #[a] //~ ERROR: custom attributes cannot be applied to statements
42 println!();
43
44 // Statement, semi
45 #[a] //~ ERROR: custom attributes cannot be applied to statements
46 S;
47
48 // Statement, local
49 #[a] //~ ERROR: custom attributes cannot be applied to statements
50 let _x = 2;
51
52 // Expr
53 let _x = #[a] 2; //~ ERROR: custom attributes cannot be applied to expressions
54
55 // Opt expr
56 let _x = [#[a] 2]; //~ ERROR: custom attributes cannot be applied to expressions
57
58 // Expr macro
59 let _x = #[a] println!(); //~ ERROR: custom attributes cannot be applied to expressions
60}
61
62fn main() {
63 let _x: m!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types
64 if let m!(Some(_x)) = Some(3) {} //~ ERROR: procedural macros cannot be expanded to patterns
65
66 m!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements
67 m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements
68
69 let _x = m!(3); //~ ERROR: procedural macros cannot be expanded to expressions
70 let _x = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions
71}