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