Skip to content

How do crate-level macro attributes deal with standard library prelude? #110082

Description

@petrochenkov

Here I'll talk about hightly unstable crate-level macro attributes first, but this issue is relevant even on stable because crate level #![cfg(...)] is also such a macro (sort of), and it is supported since Rust 1.0.
This case caused issues in #108221.

We assume that macros work with token streams.
Implicitly injected extern prelude does not have any token representation, so I conclude that crate-level macro attributes should only receive explicitly written user code as input (collected during token collection as usual).

Now the question is how and when standard library prelude is added to output of a crate level attribute (including #![cfg(FALSE)]) because eventually it should be added there.

Note: #104633 is a similar issue discussing the fate of #![feature] attributes on a fully unconfigured crate.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specifically

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions