Skip to content

Document behavior of #[cfg] in macros #836

Open
@RalfJung

Description

@RalfJung

The macro reference should explain how #[cfg] and #[cfg_attr(...)] behave inside macros.

Does this macro check the allow_clippy flag of the crate the macro is defined in, or of the crate the macro is used in?

macro_rules! field_check {
    ($type:path, $field:tt) => {
        // Make sure the field actually exists. This line ensures that a
        // compile-time error is generated if $field is accessed through a
        // Deref impl.
        #[cfg_attr(allow_clippy, allow(clippy::unneeded_field_pattern))]
        let $type { $field: _, .. };
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions