]> git.lizzy.rs Git - rust.git/blob - src/test/ui/parser/attr-stmt-expr-attr-bad.rs
469c3855c32addc120436b6aad0b05006a303d33
[rust.git] / src / test / ui / parser / attr-stmt-expr-attr-bad.rs
1 fn main() {}
2
3 #[cfg(FALSE)] fn e() { let _ = box #![attr] 0; }
4 //~^ ERROR an inner attribute is not permitted in this context
5 #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
6 //~^ ERROR expected expression, found `]`
7 #[cfg(FALSE)] fn e() { let _ = foo#[attr](); }
8 //~^ ERROR expected one of
9 #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); }
10 //~^ ERROR an inner attribute is not permitted in this context
11 //~| ERROR expected expression, found `)`
12 #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); }
13 //~^ ERROR an inner attribute is not permitted in this context
14 //~| ERROR expected expression, found `)`
15 #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; }
16 //~^ ERROR an inner attribute is not permitted in this context
17 #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; }
18 //~^ ERROR an inner attribute is not permitted in this context
19 #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; }
20 //~^ ERROR an inner attribute is not permitted in this context
21 #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; }
22 //~^ ERROR expected one of
23 #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; }
24 //~^ ERROR an inner attribute is not permitted in this context
25 #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; }
26 //~^ ERROR an inner attribute is not permitted in this context
27 #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; }
28 //~^ ERROR an inner attribute is not permitted in this context
29 #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; }
30 //~^ ERROR an inner attribute is not permitted in this context
31 #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; }
32 //~^ ERROR expected expression, found `..`
33 #[cfg(FALSE)] fn e() { let _ = #[attr] ..; }
34 //~^ ERROR expected expression, found `..`
35 #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; }
36 //~^ ERROR an inner attribute is not permitted in this context
37 #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }
38 //~^ ERROR an inner attribute is not permitted in this context
39 #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }
40 //~^ ERROR outer attributes are not allowed on `if`
41 #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; }
42 //~^ ERROR an inner attribute is not permitted in this context
43 #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; }
44 //~^ ERROR expected one of
45 #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }
46 //~^ ERROR outer attributes are not allowed on `if`
47 #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }
48 //~^ ERROR an inner attribute is not permitted in this context
49 #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }
50 //~^ ERROR outer attributes are not allowed on `if`
51 #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }
52 //~^ ERROR outer attributes are not allowed on `if`
53 #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }
54 //~^ ERROR an inner attribute is not permitted in this context
55 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }
56 //~^ ERROR outer attributes are not allowed on `if`
57 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; }
58 //~^ ERROR an inner attribute is not permitted in this context
59 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; }
60 //~^ ERROR expected one of
61 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }
62 //~^ ERROR outer attributes are not allowed on `if`
63 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }
64 //~^ ERROR an inner attribute is not permitted in this context
65 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; }
66 //~^ ERROR outer attributes are not allowed on `if`
67 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; }
68 //~^ ERROR outer attributes are not allowed on `if`
69 #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; }
70 //~^ ERROR an inner attribute is not permitted in this context
71
72 #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; }
73 //~^ ERROR an inner attribute is not permitted following an outer attribute
74 #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; }
75 //~^ ERROR an inner attribute is not permitted following an outer attribute
76 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); }
77 //~^ ERROR an inner attribute is not permitted following an outer attribute
78 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; }
79 //~^ ERROR an inner attribute is not permitted following an outer attribute
80 #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; }
81 //~^ ERROR an inner attribute is not permitted following an outer attribute
82
83 // FIXME: Allow attributes in pattern constexprs?
84 // note: requires parens in patterns to allow disambiguation
85
86 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
87 //~^ ERROR inclusive range with no end
88 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
89 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
90 //~^ ERROR inclusive range with no end
91 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
92 #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } }
93 //~^ ERROR unexpected token: `#`
94 #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
95 //~^ ERROR inclusive range with no end
96 //~| ERROR expected one of `=>`, `if`, or `|`, found `#`
97
98 #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
99 //~^ ERROR unexpected token: `#`
100 //~| ERROR expected one of `.`
101 #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
102 //~^ ERROR unexpected token: `#`
103 //~| ERROR expected one of `.`
104
105 // make sure we don't catch this bug again...
106 #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } }
107 //~^ ERROR expected statement after outer attribute
108 #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } }
109 //~^ ERROR expected statement after outer attribute