Skip to content

Commit f09d231

Browse files
nbdd0121ojeda
authored andcommitted
rust: bitfield: mark Debug impl as #[inline]
A `Debug` impl is for debugging and is normally not used, and therefore should ideally not be code-generated unless used. However, Rust has no way of knowing if a dependent crate is going to use the trait impl or not, so unless it is marked as `#[inline]`, it will be code-generated in the defining crate (as it is not generic). Mark the impl generated by bitfield macro `#[inline]`, so they do not stay in the binary unless used. This reduces nova-core.o .text by 17% (from 151922 bytes to 125676 bytes). Signed-off-by: Gary Guo <gary@garyguo.net> Fixes: b7b8b4c ("rust: extract `bitfield!` macro from `register!`") Acked-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260611190555.2298991-1-gary@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 6b5a2b7 commit f09d231

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

rust/kernel/bitfield.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ macro_rules! bitfield {
535535
// `Debug` implementation.
536536
(@debug $name:ident { $($field:ident;)* }) => {
537537
impl ::kernel::fmt::Debug for $name {
538+
#[inline]
538539
fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result {
539540
f.debug_struct(stringify!($name))
540541
.field("<raw>", &::kernel::prelude::fmt!("{:#x}", self.inner))

0 commit comments

Comments
 (0)