* [PATCH] rust: alloc: Fix unused import warning
@ 2024-06-20 2:11 Ethan D. Twardy
2024-06-20 7:49 ` Miguel Ojeda
0 siblings, 1 reply; 2+ messages in thread
From: Ethan D. Twardy @ 2024-06-20 2:11 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Danilo Krummrich, Ethan D. Twardy, open list:RUST,
open list
core::ptr is only used in code that's not compiled during test, which
causes rustc to emit the below warning while building the rusttest
target. Add a conditional attribute to match conditions at the usage
site.
warning: unused import: `core::ptr`
--> rust/kernel/alloc/vec_ext.rs:7:5
|
7 | use core::ptr;
| ^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
Signed-off-by: Ethan D. Twardy <ethan.twardy@gmail.com>
diff --git a/rust/kernel/alloc/vec_ext.rs b/rust/kernel/alloc/vec_ext.rs
index e9a81052728a..96d7cbff96dd 100644
--- a/rust/kernel/alloc/vec_ext.rs
+++ b/rust/kernel/alloc/vec_ext.rs
@@ -4,6 +4,8 @@
use super::{AllocError, Flags};
use alloc::vec::Vec;
+
+#[cfg(not(any(test, testlib)))]
use core::ptr;
/// Extensions to [`Vec`].
base-commit: 39e6bf7394d852b17fb083a85fee5890b445908c
--
2.44.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] rust: alloc: Fix unused import warning
2024-06-20 2:11 [PATCH] rust: alloc: Fix unused import warning Ethan D. Twardy
@ 2024-06-20 7:49 ` Miguel Ojeda
0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2024-06-20 7:49 UTC (permalink / raw)
To: Ethan D. Twardy
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Danilo Krummrich, open list:RUST, open list
On Thu, Jun 20, 2024 at 4:11 AM Ethan D. Twardy <ethan.twardy@gmail.com> wrote:
>
> core::ptr is only used in code that's not compiled during test, which
> causes rustc to emit the below warning while building the rusttest
> target. Add a conditional attribute to match conditions at the usage
> site.
We have an alternative fix (that avoids conditional compilation) for
this one in the `rust-fixes` branch that I am planning to send to
Linus this week.
https://lore.kernel.org/r/20240519210735.587323-1-ojeda@kernel.org
If that one does not fix the issue for you, please let me know!
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-20 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-20 2:11 [PATCH] rust: alloc: Fix unused import warning Ethan D. Twardy
2024-06-20 7:49 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox