1 // Tests that lint levels can be set for late lints.
7 enum_intrinsics_non_enums,
8 clashing_extern_declarations
12 use core::mem::{Discriminant, discriminant};
14 // The following is a check of the lints used here to verify they do not warn
16 pub fn missing_docs_allowed() {} // missing_docs
17 fn dyn_drop_allowed(_x: Box<dyn Drop>) {} // dyn_drop
18 fn verify_no_warnings() {
19 discriminant::<i32>(&123); // enum_intrinsics_non_enums
20 let x: u8 = 1000; // overflowing_literals
21 let NON_SNAKE_CASE = 1; // non_snake_case
23 mod clashing_extern_allowed {
29 fn extern_allowed(_: i32); // clashing_extern_declarations
32 // ################## Types
35 pub type MissingDocType = i32; //~ ERROR missing documentation for a type alias
37 // There aren't any late lints that I can find that can be easily used with types.
38 // type BareFnPtr = fn(#[deny()]i32);
39 // type BareFnPtrVariadic = extern "C" fn(i32, #[deny()]...);
41 // ################## Items
43 pub struct ItemOuter; //~ ERROR missing documentation for a struct
45 pub mod module_inner { //~ ERROR missing documentation for a module
46 #![deny(missing_docs)]
47 pub fn missing_inner() {} //~ ERROR missing documentation for a function
50 pub struct Associated;
52 #![deny(missing_docs)]
54 pub fn inherent_denied_from_inner() {} //~ ERROR missing documentation for an associated function
59 pub fn inherent_fn() {} //~ ERROR missing documentation for an associated function
62 pub const INHERENT_CONST: i32 = 1; //~ ERROR missing documentation for an associated constant
65 pub trait TraitInner { //~ ERROR missing documentation for a trait
66 #![deny(missing_docs)]
69 pub trait AssociatedTraitInner { //~ ERROR missing documentation for a trait
70 #![deny(missing_docs)]
72 fn denied_from_inner() {} //~ ERROR missing documentation for an associated function
75 pub trait AssociatedTrait {
76 fn denied_from_inner(_x: Box<dyn Drop>) {} // Used below
79 fn assoc_fn() {} //~ ERROR missing documentation for an associated function
82 const ASSOC_CONST: u8 = 1; //~ ERROR missing documentation for an associated constant
85 type AssocType; //~ ERROR missing documentation for an associated type
90 impl AssociatedTrait for Associated {
93 fn denied_from_inner(_x: Box<dyn Drop>) {} //~ ERROR types that do not implement `Drop`
95 #[deny(enum_intrinsics_non_enums)]
96 fn assoc_fn() { discriminant::<i32>(&123); } //~ ERROR the return value of
98 #[deny(overflowing_literals)] const ASSOC_CONST: u8 = 1000; //~ ERROR literal out of range
103 // There aren't any late lints that can apply to a field that I can find.
104 // non_snake_case doesn't work on fields
105 // struct StructFields {
108 // struct StructTuple(#[deny()]i32);
111 #[deny(missing_docs)]
112 Variant1, //~ ERROR missing documentation for a variant
115 mod clashing_extern {
122 #![deny(clashing_extern_declarations)]
123 fn clashing1(_: i32); //~ ERROR `clashing1` redeclared with a different signature
127 #[deny(clashing_extern_declarations)]
128 fn clashing2(_: i32); //~ ERROR `clashing2` redeclared with a different signature
131 fn function(#[deny(non_snake_case)] PARAM: i32) {} //~ ERROR variable `PARAM` should have a snake case name
132 // There aren't any late lints that can apply to generics that I can find.
133 // fn generics<#[deny()]T>() {}
136 // ################## Statements
138 #[deny(enum_intrinsics_non_enums)]
139 let _ = discriminant::<i32>(&123); //~ ERROR the return value of
143 // ################## Expressions
145 let closure = |#[deny(non_snake_case)] PARAM: i32| {}; //~ ERROR variable `PARAM` should have a snake case name
147 struct Match{f1: i32}
148 // I can't find any late lints for patterns.
149 // let f = Match{#[deny()]f1: 123};
151 let f = Match{f1: 123};
153 #![deny(enum_intrinsics_non_enums)]
155 discriminant::<i32>(&123); //~ ERROR the return value of
159 #[deny(enum_intrinsics_non_enums)]
161 discriminant::<i32>(&123); //~ ERROR the return value of
167 #![deny(enum_intrinsics_non_enums)]
168 discriminant::<i32>(&123); //~ ERROR the return value of
171 #[deny(enum_intrinsics_non_enums)]
172 discriminant::<i32>(&123); //~ ERROR the return value of
175 // Before expression as a statement.
176 #[deny(enum_intrinsics_non_enums)]
177 discriminant::<i32>(&123); //~ ERROR the return value of
179 [#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)]; //~ ERROR the return value of
180 (#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123),); //~ ERROR the return value of
181 fn call(p: Discriminant<i32>) {}
182 call(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); //~ ERROR the return value of
183 struct TupleStruct(Discriminant<i32>);
184 TupleStruct(#[deny(enum_intrinsics_non_enums)] discriminant::<i32>(&123)); //~ ERROR the return value of
188 // ################## Patterns
190 // There aren't any late lints that I can find that apply to pattern fields.
192 // struct PatField{f1: i32, f2: i32};
193 // let f = PatField{f1: 1, f2: 2};
194 // let PatField{#[deny()]f1, #[deny()]..} = f;