@@ -24,9 +24,17 @@ use foo::*;
24
24
#[ foo:: a] //~ ERROR: paths of length greater than one
25
25
fn _test ( ) { }
26
26
27
+ fn _test_inner ( ) {
28
+ #![ a] // OK
29
+ }
30
+
27
31
#[ a] //~ ERROR: custom attributes cannot be applied to modules
28
32
mod _test2 { }
29
33
34
+ mod _test2_inner {
35
+ #![ a] //~ ERROR: custom attributes cannot be applied to modules
36
+ }
37
+
30
38
#[ a = y] //~ ERROR: must only be followed by a delimiter token
31
39
fn _test3 ( ) { }
32
40
@@ -36,19 +44,40 @@ fn _test4() {}
36
44
#[ a ( ) = ] //~ ERROR: must only be followed by a delimiter token
37
45
fn _test5 ( ) { }
38
46
39
- fn main ( ) {
47
+ fn attrs ( ) {
48
+ // Statement, item
49
+ #[ a] // OK
50
+ struct S ;
51
+
52
+ // Statement, macro
53
+ #[ a] //~ ERROR: custom attributes cannot be applied to statements
54
+ println ! ( ) ;
55
+
56
+ // Statement, semi
57
+ #[ a] //~ ERROR: custom attributes cannot be applied to statements
58
+ S ;
59
+
60
+ // Statement, local
40
61
#[ a] //~ ERROR: custom attributes cannot be applied to statements
41
62
let _x = 2 ;
42
- let _x = #[ a] 2 ;
43
- //~^ ERROR: custom attributes cannot be applied to expressions
44
-
45
- let _x: m ! ( u32 ) = 3 ;
46
- //~^ ERROR: procedural macros cannot be expanded to types
47
- if let m ! ( Some ( _x) ) = Some ( 3 ) {
48
- //~^ ERROR: procedural macros cannot be expanded to patterns
49
- }
50
- let _x = m ! ( 3 ) ;
51
- //~^ ERROR: procedural macros cannot be expanded to expressions
52
- m ! ( let _x = 3 ; ) ;
53
- //~^ ERROR: procedural macros cannot be expanded to statements
63
+
64
+ // Expr
65
+ let _x = #[ a] 2 ; //~ ERROR: custom attributes cannot be applied to expressions
66
+
67
+ // Opt expr
68
+ let _x = [ #[ a] 2 ] ; //~ ERROR: custom attributes cannot be applied to expressions
69
+
70
+ // Expr macro
71
+ let _x = #[ a] println ! ( ) ; //~ ERROR: custom attributes cannot be applied to expressions
72
+ }
73
+
74
+ fn main ( ) {
75
+ let _x: m ! ( u32 ) = 3 ; //~ ERROR: procedural macros cannot be expanded to types
76
+ if let m ! ( Some ( _x) ) = Some ( 3 ) { } //~ ERROR: procedural macros cannot be expanded to patterns
77
+
78
+ m ! ( struct S ; ) ; //~ ERROR: procedural macros cannot be expanded to statements
79
+ m ! ( let _x = 3 ; ) ; //~ ERROR: procedural macros cannot be expanded to statements
80
+
81
+ let _x = m ! ( 3 ) ; //~ ERROR: procedural macros cannot be expanded to expressions
82
+ let _x = [ m ! ( 3 ) ] ; //~ ERROR: procedural macros cannot be expanded to expressions
54
83
}
0 commit comments