<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/rust/macros/fmt.rs, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-01-04T22:51:35+00:00</updated>
<entry>
<title>rust: fmt: fix formatting expressions</title>
<updated>2026-01-04T22:51:35+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@gmail.com</email>
</author>
<published>2026-01-04T13:00:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f1db6538794f5af081940850a7976319d376110a'/>
<id>urn:sha1:f1db6538794f5af081940850a7976319d376110a</id>
<content type='text'>
Allow usage like `pr_info!("one + 1 = {}", one + 1)` to compile by
ensuring that a reference is taken to the entire expression.

[ The errors we would get otherwise look like:

    error[E0277]: `kernel::fmt::Adapter&lt;i32&gt;` doesn't implement `core::fmt::Display`
      --&gt; ../samples/rust/rust_minimal.rs:34:9
       |
    34 |         pr_info!("one + 1 = {}", one + 1);
       |         ^^^^^^^^^^^^^^^^^^^^--^^^^^^^^^^^
       |         |                   |
       |         |                   required by this formatting parameter
       |         `kernel::fmt::Adapter&lt;i32&gt;` cannot be formatted with the default formatter
       |
       = help: the trait `core::fmt::Display` is not implemented for `kernel::fmt::Adapter&lt;i32&gt;`
       = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
       = help: the trait `core::fmt::Display` is implemented for `kernel::fmt::Adapter&lt;&amp;T&gt;`
       = note: this error originates in the macro `$crate::print_macro` which comes from the expansion of the macro `pr_info` (in Nightly builds, run with -Z macro-backtrace for more info)

    - Miguel ]

Fixes: c5cf01ba8dfe ("rust: support formatting of foreign types")
Reported-by: Janne Grunau &lt;j@jannau.net&gt;
Closes: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Custom.20formatting/near/566219493
Signed-off-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Tested-by: Janne Grunau &lt;j@jannau.net&gt;
Reviewed-by: Janne Grunau &lt;j@jannau.net&gt;
Link: https://patch.msgid.link/20260104-fmt-paren-v1-1-6b84bc0da78f@gmail.com
[ Added Signed-off-by back. Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: support formatting of foreign types</title>
<updated>2025-10-22T05:15:31+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@gmail.com</email>
</author>
<published>2025-10-18T19:16:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c5cf01ba8dfe9c0f631ace6f64ec436303783000'/>
<id>urn:sha1:c5cf01ba8dfe9c0f631ace6f64ec436303783000</id>
<content type='text'>
Introduce a `fmt!` macro which wraps all arguments in
`kernel::fmt::Adapter` and a `kernel::fmt::Display` trait. This enables
formatting of foreign types (like `core::ffi::CStr`) that do not
implement `core::fmt::Display` due to concerns around lossy conversions
which do not apply in the kernel.

Suggested-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/Custom.20formatting/with/516476467
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Acked-by: Danilo Krummrich &lt;dakr@kernel.org&gt;
Reviewed-by: Benno Lossin &lt;lossin@kernel.org&gt;
Signed-off-by: Tamir Duberstein &lt;tamird@gmail.com&gt;
Link: https://patch.msgid.link/20251018-cstr-core-v18-15-9378a54385f8@gmail.com
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
</feed>
