diff mbox series

[1/3] rust: pin-init: internal: skip rustfmt formatting of kernel-only module

Message ID 20250414195928.129040-2-benno.lossin@proton.me (mailing list archive)
State New
Headers show
Series pin-init: fix issues found with new CI | expand

Commit Message

Benno Lossin April 14, 2025, 8 p.m. UTC
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@proton.me>
---
 rust/pin-init/internal/src/lib.rs | 1 +
 1 file changed, 1 insertion(+)

Comments

Christian Schrefl April 16, 2025, 3:23 p.m. UTC | #1
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@proton.me>
> ---
>  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@gmail.com>
diff mbox series

Patch

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]