]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/missing_inline_in_public_items.txt
Rollup merge of #101389 - lukaslueg:rcgetmutdocs, r=m-ou-se
[rust.git] / src / tools / clippy / src / docs / missing_inline_in_public_items.txt
1 ### What it does
2 It lints if an exported function, method, trait method with default impl,
3 or trait method impl is not `#[inline]`.
4
5 ### Why is this bad?
6 In general, it is not. Functions can be inlined across
7 crates when that's profitable as long as any form of LTO is used. When LTO is disabled,
8 functions that are not `#[inline]` cannot be inlined across crates. Certain types of crates
9 might intend for most of the methods in their public API to be able to be inlined across
10 crates even when LTO is disabled. For these types of crates, enabling this lint might make
11 sense. It allows the crate to require all exported methods to be `#[inline]` by default, and
12 then opt out for specific methods where this might not make sense.
13
14 ### Example
15 ```
16 pub fn foo() {} // missing #[inline]
17 fn ok() {} // ok
18 #[inline] pub fn bar() {} // ok
19 #[inline(always)] pub fn baz() {} // ok
20
21 pub trait Bar {
22   fn bar(); // ok
23   fn def_bar() {} // missing #[inline]
24 }
25
26 struct Baz;
27 impl Baz {
28    fn private() {} // ok
29 }
30
31 impl Bar for Baz {
32   fn bar() {} // ok - Baz is not exported
33 }
34
35 pub struct PubBaz;
36 impl PubBaz {
37    fn private() {} // ok
38    pub fn not_private() {} // missing #[inline]
39 }
40
41 impl Bar for PubBaz {
42    fn bar() {} // missing #[inline]
43    fn def_bar() {} // missing #[inline]
44 }
45 ```