Skip to content

Consider expanding through an indirect macro #25

Closed
@gnzlbg

Description

@gnzlbg

See rust-lang/rfcs#2523 (comment), where @ogoffart mentions that:

I suppose it would not make sense to relax the parsing rules of items that are disabled by #[cfg]

So one must wrap the item inside a macro such as cfg-if!{...} but which would not expand the items for the disabled configuration. Something like this should work: #[cfg($cfg)] identity!{ $($body)* }.

Currently in libc we can't write:

cfg_if! {
    if #[cfg(foo)] {
        #[repr(align(16))] struct F;
    }
}

because older libsyntax versions chuckle on the align(16) (https://rust.godbolt.org/z/eZYANH). It would be nice if cfg_if! could be improved with such an indirect macro approach to make that work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions