File: invalid.rs

package info (click to toggle)
rust-easy-ext 1.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: makefile: 2
file content (65 lines) | stat: -rw-r--r-- 1,482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: Apache-2.0 OR MIT

mod basic {
    use easy_ext::ext;

    #[ext(NoValueConst)]
    impl str {
        const ASSOC: u8; //~ ERROR expected `=`
    }
    #[ext(NoValueTy)]
    impl str {
        type Assoc; //~ ERROR expected `=`
    }
    #[ext(NoValueFn)]
    impl str {
        fn assoc(); //~ ERROR expected `{`
    }

    #[ext(Macro)]
    impl str {
        mac!(); //~ ERROR expected one of: `default`, `fn`, `const`, `type`
    }

    #[rustfmt::skip]
    #[ext(ExtraArg,)] //~ ERROR unexpected token
    impl str {}

    #[ext(pub OldVisSyntax1)] //~ ERROR use `pub impl` instead
    impl str {}

    #[ext(pub(crate) OldVisSyntax2)] //~ ERROR use `pub(crate) impl` instead
    impl str {}
}

mod visibility {
    use easy_ext::ext;

    #[ext(AssocLevel1)]
    impl str {
        pub const ASSOC1: u8 = 1;
        const ASSOC2: u8 = 2; //~ ERROR all associated items must have a visibility of `pub`
    }

    #[ext(AssocLevel2)]
    impl str {
        fn assoc1(&self) {}

        pub fn assoc2(&self) {} //~ ERROR all associated items must have inherited visibility
    }

    #[ext(AssocLevel3)]
    impl str {
        pub(crate) type Assoc1 = ();
        pub type Assoc2 = (); //~ ERROR all associated items must have a visibility of `pub(crate)`
    }

    #[ext(ImplLevel1)]
    pub impl str {
        fn assoc1(&self) {}

        pub fn assoc2(&self) {} //~ ERROR all associated items must have inherited visibility
    }
}

fn main() {}