Elsanti
unread,Feb 25, 2026, 2:45:57 PM (2 days ago) Feb 25Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to brendan...@linux.dev, davi...@google.com, oj...@kernel.org, raem...@gmail.com, bo...@kernel.org, ga...@garyguo.net, bjor...@protonmail.com, los...@kernel.org, a.hin...@kernel.org, alic...@google.com, tmg...@umich.edu, da...@kernel.org, linux-k...@vger.kernel.org, kuni...@googlegroups.com, rust-fo...@vger.kernel.org, linux-...@vger.kernel.org, Elsanti
Replace the TODO-only removal of #[test] attributes with a
retain_mut-based filter that works with the current MSRV.
This preserves test detection without depending on
Vec::extract_if and keeps the generated KUnit wrappers correct.
Signed-off-by: Elsanti <
santiagoj...@gmail.com>
---
rust/macros/kunit.rs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/rust/macros/kunit.rs b/rust/macros/kunit.rs
index 6be880d634e2..e064419bfc10 100644
--- a/rust/macros/kunit.rs
+++ b/rust/macros/kunit.rs
@@ -87,10 +87,15 @@ pub(crate) fn kunit_tests(test_suite: Ident, mut module: ItemMod) -> Result<Toke
continue;
};
- // TODO: Replace below with `extract_if` when MSRV is bumped above 1.85.
- let before_len = f.attrs.len();
- f.attrs.retain(|attr| !attr.path().is_ident("test"));
- if f.attrs.len() == before_len {
+ let mut had_test_attr = false;
+ f.attrs.retain_mut(|attr| {
+ let is_test = attr.path().is_ident("test");
+ if is_test {
+ had_test_attr = true;
+ }
+ !is_test
+ });
+ if !had_test_attr {
processed_items.push(Item::Fn(f));
continue;
}
--
2.53.0