• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //! Tests lints that should compile.
16 //!
17 //! Tests (unit or integration) don't trigger missing_docs, so this must be a binary or library.
18 //! Binary is simpler. Alternatively, this could be part of the ui/compile-fail test fixture.
19 
20 /// Tests that basic attributes propagate, like documentation.
21 pub mod docs {
22     #![deny(missing_docs)]
23     use open_enum::open_enum;
24 
25     #[open_enum]
26     /// This struct has documentation.
27     pub enum ImportantLetters {
28         /// A is the first letter of the English alphabet.
29         A,
30 
31         /// B is for Bananaphone.
32         B,
33     }
34 }
35 
36 /// Tests that allow lints propagate through an open enum definition correctly.
37 pub mod allow_lint_propagates {
38     #![deny(missing_docs)]
39     use open_enum::open_enum;
40 
41     // Checks that local lints propagate correctly.
42     #[open_enum]
43     #[allow(missing_docs)]
44     pub enum HasLintTop {
45         A,
46         B,
47     }
48 
49     #[allow(missing_docs)]
50     #[open_enum]
51     pub enum HasLintBottom {
52         A,
53         B,
54     }
55 }
56 
57 pub mod clippy {
58     // We should pass this, as this is a newtype.
59     #![deny(clippy::exhaustive_structs)]
60 
61     #[open_enum::open_enum]
62     pub enum Foo {
63         Bar,
64         Baz,
65     }
66 }
67 
68 pub mod nonliteral {
69     #![deny(dead_code)]
70 
71     #[open_enum::open_enum]
72     #[derive(PartialEq, Eq)] // for some reason this has to be here to get a dead_code lint to trigger
73     #[repr(u32)]
74     pub enum Fuzz {
75         Balls = 1 << 1,
76     }
77 }
78 
main()79 fn main() {}
80