]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/missing_inline.rs
Rollup merge of #99474 - aDotInTheVoid:rustdoc-json-noinline-test-cleanup, r=CraftSpider
[rust.git] / src / tools / clippy / tests / ui / missing_inline.rs
1 #![warn(clippy::missing_inline_in_public_items)]
2 #![crate_type = "dylib"]
3 // When denying at the crate level, be sure to not get random warnings from the
4 // injected intrinsics by the compiler.
5 #![allow(dead_code, non_snake_case)]
6
7 type Typedef = String;
8 pub type PubTypedef = String;
9
10 struct Foo; // ok
11 pub struct PubFoo; // ok
12 enum FooE {} // ok
13 pub enum PubFooE {} // ok
14
15 mod module {} // ok
16 pub mod pub_module {} // ok
17
18 fn foo() {}
19 pub fn pub_foo() {} // missing #[inline]
20 #[inline]
21 pub fn pub_foo_inline() {} // ok
22 #[inline(always)]
23 pub fn pub_foo_inline_always() {} // ok
24
25 #[allow(clippy::missing_inline_in_public_items)]
26 pub fn pub_foo_no_inline() {}
27
28 trait Bar {
29     fn Bar_a(); // ok
30     fn Bar_b() {} // ok
31 }
32
33 pub trait PubBar {
34     fn PubBar_a(); // ok
35     fn PubBar_b() {} // missing #[inline]
36     #[inline]
37     fn PubBar_c() {} // ok
38 }
39
40 // none of these need inline because Foo is not exported
41 impl PubBar for Foo {
42     fn PubBar_a() {} // ok
43     fn PubBar_b() {} // ok
44     fn PubBar_c() {} // ok
45 }
46
47 // all of these need inline because PubFoo is exported
48 impl PubBar for PubFoo {
49     fn PubBar_a() {} // missing #[inline]
50     fn PubBar_b() {} // missing #[inline]
51     fn PubBar_c() {} // missing #[inline]
52 }
53
54 // do not need inline because Foo is not exported
55 impl Foo {
56     fn FooImpl() {} // ok
57 }
58
59 // need inline because PubFoo is exported
60 impl PubFoo {
61     pub fn PubFooImpl() {} // missing #[inline]
62 }
63
64 // do not lint this since users cannot control the external code
65 #[derive(Debug)]
66 pub struct S;