diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-05-30 09:44:14 +0200 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-05-30 09:44:14 +0200 |
| commit | 89037ea18f101e2e586feb81d2595a47ae42da46 (patch) | |
| tree | e5934c662d0ace18bdc16cccb6c2342f69f3e5d7 /clippy_lints/src/missing_inline.rs | |
| parent | bda742762157d33dc2b2b52c451bcbf4d5237f08 (diff) | |
| parent | da4b2127c0a144699b946eec3c8c9d4fd7050c17 (diff) | |
| download | rust-89037ea18f101e2e586feb81d2595a47ae42da46.tar.gz rust-89037ea18f101e2e586feb81d2595a47ae42da46.zip | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/missing_inline.rs')
| -rw-r--r-- | clippy_lints/src/missing_inline.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index c6a76478806..33a14d8b7fe 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -10,13 +10,16 @@ declare_clippy_lint! { /// 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 + /// ### Why restrict this? + /// When a function is not marked `#[inline]`, it is not + /// [a “small” candidate for automatic inlining][small], and LTO is not in use, then it is not + /// possible for the function to be inlined into the code of any crate other than the one in + /// which it is defined. Depending on the role of the function and the relationship of the crates, + /// this could significantly reduce performance. + /// + /// 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. + /// This lint allows those crates to require all exported methods to be `#[inline]` by default, and /// then opt out for specific methods where this might not make sense. /// /// ### Example @@ -51,6 +54,8 @@ declare_clippy_lint! { /// fn def_bar() {} // missing #[inline] /// } /// ``` + /// + /// [small]: https://github.com/rust-lang/rust/pull/116505 #[clippy::version = "pre 1.29.0"] pub MISSING_INLINE_IN_PUBLIC_ITEMS, restriction, |
