1 //! False-positive tests to ensure we don't suggest `const` for things where it would cause a
3 //! The .stderr output of this test should be empty. Otherwise it's a bug somewhere.
5 #![warn(clippy::missing_const_for_fn)]
10 // This should not be linted because it's already const
11 const fn already_const() -> i32 { 32 }
14 // This should not be linted because it's already const
15 pub const fn already_const() -> i32 { 32 }
18 // Allowing on this function, because it would lint, which we don't want in this case.
19 #[allow(clippy::missing_const_for_fn)]
20 fn random() -> u32 { 42 }
22 // We should not suggest to make this function `const` because `random()` is non-const
23 fn random_caller() -> u32 {
29 // We should not suggest to make this function `const` because const functions are not allowed to
30 // refer to a static variable
36 // Also main should not be suggested to be made const
38 // We should also be sure to not lint on closures
39 let add_one_v2 = |x: u32| -> u32 { x + 1 };
43 // This should not be suggested to be made const
44 // (rustc restriction)
48 // Don't lint custom entrypoints either
50 fn init(num: isize, something: *const *const u8) -> isize { 1 }