]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: pin-init: examples: error: use `Error` in `fn main()`
authorBenno Lossin <lossin@kernel.org>
Mon, 18 Aug 2025 13:18:44 +0000 (15:18 +0200)
committerBenno Lossin <lossin@kernel.org>
Thu, 11 Sep 2025 21:25:54 +0000 (23:25 +0200)
When running this example with no cargo features enabled, the compiler
warns on 1.89:

  error: struct `Error` is never constructed
    --> examples/error.rs:11:12
     |
  11 | pub struct Error;
     |            ^^^^^
     |
     = note: `-D dead-code` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(dead_code)]`

Thus use the error in the main function to avoid this warning.

Signed-off-by: Benno Lossin <lossin@kernel.org>
rust/pin-init/examples/error.rs

index e0cc258746ce5235cfee0ded45c2efd89d37848a..8f4e135eb8ba53c9a2f71de7baddbcf0a56879f7 100644 (file)
@@ -24,4 +24,6 @@ impl From<AllocError> for Error {
 }
 
 #[allow(dead_code)]
-fn main() {}
+fn main() {
+    let _ = Error;
+}