Skip to content

Disallow attribute macros named cfg #53531

Description

@djrenren

#[cfg()] runs before name resolution so no proc macro attribute named cfg could ever be called. We should make this a hard error at the declaration site to protect people from this confusion.

Activity

  1. djrenren commented on Aug 20, 2018

    @djrenren
    ContributorAuthor

    I think this would be a good issue for mentoring. I'm happy to help out.

  2. Havvy commented on Aug 20, 2018

    @Havvy
    Contributor

    The test attribute seems to be similarly ignored.

  3. otavio commented on Aug 20, 2018

    @otavio
    Contributor

    I could give it a go. As a first time contributor please be patient 😉

  4. djrenren commented on Aug 20, 2018

    @djrenren
    ContributorAuthor

    @Havvy Yeah, though that's not by necessity, so I wanna do a crater run and see if we could give it normal resolution.

  5. djrenren commented on Aug 20, 2018

    @djrenren
    ContributorAuthor

    @otavio That's awesome! I'm happy to help in any way you need.

    I recommend taking a look at src/libsyntax_ext/proc_macro_registrar.rs

  6. eddyb commented on Aug 21, 2018

    @eddyb
    Contributor

    I'd check it during name resolution instead, so you can do #[foo::cfg(...)] just fine, but not import it unqualified.

    cc @petrochenkov

  7. petrochenkov commented on Aug 21, 2018

    @petrochenkov
    Contributor

    I have a PR in progress that resolves the penultimate item in #50911 (comment) and passes all attributes through name resolution, that includes cfg as well.

    (Disallowing proc macros named cfg is both too much - #[foo::cfg] is ok, and not enough - use my_non_cfg_attr_macro as cfg;).

  8. djrenren commented on Aug 21, 2018

    @djrenren
    ContributorAuthor

    @petrochenkov Ah yeah I hadn't thought about that! That's awesome.

  9. added a commit that references this issue on Sep 3, 2018
  10. added a commit that references this issue on Sep 11, 2018
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions