Re: [PATCH v2] rust: add new macro for common bitmap operations
From: Benno Lossin
Date: Tue Mar 25 2025 - 09:48:26 EST
On Tue Mar 25, 2025 at 2:10 PM CET, Filipe Xavier wrote:
> +#[macro_export]
> +macro_rules! impl_flags {
> + (
> + $(#[$outer_flags:meta])* $vis_flags:vis $flags:ident,
> + $(#[$outer_flag:meta])* $vis_flag:vis $flag:ident,
> + $ty:ty
> + ) => {
> + $(#[$outer_flags])*
> + #[repr(transparent)]
> + #[derive(Copy, Clone, Default, PartialEq, Eq)]
> + $vis_flags struct $flags($ty);
> +
> + $(#[$outer_flag])*
> + #[derive(Copy, Clone, PartialEq, Eq)]
> + $vis_flag struct $flag($ty);
> +
> + impl From<$flag> for $flags {
Please use absolute paths to refer to items, in this case
`::core::convert::From` (note the leading `::`). More cases below.
I filed an issue to add a new clippy lint to catch this:
https://github.com/rust-lang/rust-clippy/issues/14472
---
Cheers,
Benno
> + #[inline]
> + fn from(value: $flag) -> Self {
> + Self(value.0)
> + }
> + }