Debian Codegraph @

tests/ui/invalid.rs

raw
1 // SPDX-License-Identifier: Apache-2.0 OR MIT
2
3 mod basic {
4 use easy_ext::ext;
5
6 #[ext(NoValueConst)]
7 impl str {
8 const ASSOC: u8; //~ ERROR expected `=`
9 }
10 #[ext(NoValueTy)]
11 impl str {
12 type Assoc; //~ ERROR expected `=`
13 }
14 #[ext(NoValueFn)]
15 impl str {
16 fn assoc(); //~ ERROR expected `{`
17 }
18
19 #[ext(Macro)]
20 impl str {
21 mac!(); //~ ERROR expected one of: `default`, `fn`, `const`, `type`
22 }
23
24 #[rustfmt::skip]
25 #[ext(ExtraArg,)] //~ ERROR unexpected token
26 impl str {}
27
28 #[ext(pub OldVisSyntax1)] //~ ERROR use `pub impl` instead
29 impl str {}
30
31 #[ext(pub(crate) OldVisSyntax2)] //~ ERROR use `pub(crate) impl` instead
32 impl str {}
33 }
34
35 mod visibility {
36 use easy_ext::ext;
37
38 #[ext(AssocLevel1)]
39 impl str {
40 pub const ASSOC1: u8 = 1;
41 const ASSOC2: u8 = 2; //~ ERROR all associated items must have a visibility of `pub`
42 }
43
44 #[ext(AssocLevel2)]
45 impl str {
46 fn assoc1(&self) {}
47
48 pub fn assoc2(&self) {} //~ ERROR all associated items must have inherited visibility
49 }
50
51 #[ext(AssocLevel3)]
52 impl str {
53 pub(crate) type Assoc1 = ();
54 pub type Assoc2 = (); //~ ERROR all associated items must have a visibility of `pub(crate)`
55 }
56
57 #[ext(ImplLevel1)]
58 pub impl str {
59 fn assoc1(&self) {}
60
61 pub fn assoc2(&self) {} //~ ERROR all associated items must have inherited visibility
62 }
63 }
64
65 fn main() {}