Re: [PATCH 1/3] rust: pin-init: internal: skip rustfmt formatting of kernel-only module
From: Christian Schrefl
Date: Wed Apr 16 2025 - 11:24:03 EST
On 14.04.25 10:00 PM, Benno Lossin wrote:
> The `quote` module only is available in the kernel and thus running
> `cargo fmt` or `rustfmt internal/src/lib.rs` in the user-space
> repository [1] results in:
>
> error: couldn't read `~/pin-init/internal/src/../../../macros/quote.rs`: No such file or directory (os error 2)
> --> ~/pin-init/internal/src/lib.rs:25:1
> |
> 25 | mod quote;
> | ^^^^^^^^^^
>
> Error writing files: failed to resolve mod `quote`: ~/pin-init/internal/src/../../../macros/quote.rs does not exist
>
> Thus mark it with `rustfmt::skip` when compiling without kernel support.
>
> Link: https://github.com/Rust-for-Linux/pin-init [1]
> Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/a6caf1945e51da38761aab4dffa56e63e2baa218
> Signed-off-by: Benno Lossin <benno.lossin@xxxxxxxxx>
> ---
> rust/pin-init/internal/src/lib.rs | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs
> index babe5e878550..56aa9ecc1e1a 100644
> --- a/rust/pin-init/internal/src/lib.rs
> +++ b/rust/pin-init/internal/src/lib.rs
> @@ -22,6 +22,7 @@
> #[cfg(kernel)]
> #[path = "../../../macros/quote.rs"]
> #[macro_use]
> +#[cfg_attr(not(kernel), rustfmt::skip)]
> mod quote;
> #[cfg(not(kernel))]
> #[macro_use]
Reviewed-by: Christian Schrefl <chrisi.schrefl@xxxxxxxxx>