about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/empty_structs_with_brackets.fixed
blob: 22386245ffe6b596cf9a2498dcf4ef6a243d4227 (plain)
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
#![warn(clippy::empty_structs_with_brackets)]
#![allow(dead_code)]

pub struct MyEmptyStruct; // should trigger lint
//~^ empty_structs_with_brackets
struct MyEmptyTupleStruct; // should trigger lint
//~^ empty_structs_with_brackets

// should not trigger lint
struct MyCfgStruct {
    #[cfg(feature = "thisisneverenabled")]
    field: u8,
}

// should not trigger lint
struct MyCfgTupleStruct(#[cfg(feature = "thisisneverenabled")] u8);

// should not trigger lint
struct MyStruct {
    field: u8,
}
struct MyTupleStruct(usize, String); // should not trigger lint
struct MySingleTupleStruct(usize); // should not trigger lint
struct MyUnitLikeStruct; // should not trigger lint

macro_rules! empty_struct {
    ($s:ident) => {
        struct $s {}
    };
}

empty_struct!(FromMacro);

fn main() {}

mod issue15349 {
    trait Bar<T> {}
    impl<T> Bar<T> for [u8; 7] {}

    struct Foo<const N: usize>;
    //~^ empty_structs_with_brackets
    impl<const N: usize> Foo<N>
    where
        [u8; N]: Bar<[(); N]>,
    {
        fn foo() {}
    }
}