summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/missing_inline_in_public_items.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/missing_inline_in_public_items.txt')
-rw-r--r--src/tools/clippy/src/docs/missing_inline_in_public_items.txt45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/missing_inline_in_public_items.txt b/src/tools/clippy/src/docs/missing_inline_in_public_items.txt
new file mode 100644
index 000000000..d90c50fe7
--- /dev/null
+++ b/src/tools/clippy/src/docs/missing_inline_in_public_items.txt
@@ -0,0 +1,45 @@
+### What it does
+It lints if an exported function, method, trait method with default impl,
+or trait method impl is not `#[inline]`.
+
+### Why is this bad?
+In general, it is not. Functions can be inlined across
+crates when that's profitable as long as any form of LTO is used. When LTO is disabled,
+functions that are not `#[inline]` cannot be inlined across crates. Certain types of crates
+might intend for most of the methods in their public API to be able to be inlined across
+crates even when LTO is disabled. For these types of crates, enabling this lint might make
+sense. It allows the crate to require all exported methods to be `#[inline]` by default, and
+then opt out for specific methods where this might not make sense.
+
+### Example
+```
+pub fn foo() {} // missing #[inline]
+fn ok() {} // ok
+#[inline] pub fn bar() {} // ok
+#[inline(always)] pub fn baz() {} // ok
+
+pub trait Bar {
+ fn bar(); // ok
+ fn def_bar() {} // missing #[inline]
+}
+
+struct Baz;
+impl Baz {
+ fn private() {} // ok
+}
+
+impl Bar for Baz {
+ fn bar() {} // ok - Baz is not exported
+}
+
+pub struct PubBaz;
+impl PubBaz {
+ fn private() {} // ok
+ pub fn not_private() {} // missing #[inline]
+}
+
+impl Bar for PubBaz {
+ fn bar() {} // missing #[inline]
+ fn def_bar() {} // missing #[inline]
+}
+``` \ No newline at end of file