Closed
Description
What it does
Creates a warning (by default it should be disabled) to add a "#[inline(always)]" to a function (if not already present), if the function only has one caller.
It is an alternative to the "single_call_fn" lint.
It still allows the same formatting in the code, but the compiler (mostly if lto is used) will inline it and it won't affect performance.
Also, this is just a hint, assuming the compiler doesn't inline it automatically (although it is not guaranted with the hint either)
Advantage
It hints the compiler, that its best to inline the function. There are no drawbacks in size (because it is only used once). This should be a performance gain (as the jump instruction isn't needed)
Drawbacks
It slows down compile-time.
Example
fn main() {
do_something();
}
fn do_something() {
println!("Test");
}
Could be written as:
fn main() {
do_something();
}
#[inline(always)]
fn do_something() {
println!("Test");
}