File: consts.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (93 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download | duplicates (4)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//@ check-pass
//@ edition:2021
//@ rustc-env:CARGO_CRATE_NAME=non_local_def

struct Test;

trait Uto {}
const Z: () = {
    trait Uto1 {}

    impl Uto1 for Test {} // the trait is local, don't lint

    impl Uto for &Test {}
    //~^ WARN non-local `impl` definition
};

trait Ano {}
const _: () = {
    impl Ano for &Test {} // ignored since the parent is an anon-const
};

trait Uto2 {}
static A: u32 = {
    impl Uto2 for Test {}
    //~^ WARN non-local `impl` definition

    1
};

trait Uto3 {}
const B: u32 = {
    impl Uto3 for Test {}
    //~^ WARN non-local `impl` definition

    trait Uto4 {}
    impl Uto4 for Test {}

    1
};

trait Uto5 {}
fn main() {
    impl Test {
    //~^ WARN non-local `impl` definition
        fn foo() {}
    }


    const {
        impl Test {
        //~^ WARN non-local `impl` definition
            fn hoo() {}
        }

        1
    };

    const _: u32 = {
        impl Test {
        //~^ WARN non-local `impl` definition
            fn foo2() {}
        }

        1
    };

    const _: () = {
        const _: () = {
            impl Test {}
            //~^ WARN non-local `impl` definition
        };
    };
}

trait Uto9 {}
trait Uto10 {}
const _: u32 = {
    let _a = || {
        impl Uto9 for Test {}
        //~^ WARN non-local `impl` definition

        1
    };

    type A = [u32; {
        impl Uto10 for Test {}
        //~^ WARN non-local `impl` definition

        1
    }];

    1
};