Skip to content

Procedural macro crates should require at most one definition per macro name #52225

Closed

Description

@alexcrichton

Discovered by @alercah here, this crate should be rejected:

#![crate_type = "proc-macro"]

extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro]
pub fn bad(_ : TokenStream) -> TokenStream { "".parse().unwrap() }

#[proc_macro_derive(bad)]
pub fn deriver(_ : TokenStream) -> TokenStream { "".parse().unwrap() }

Activity

  1. alexcrichton commented on Jul 10, 2018

    @alexcrichton
    MemberAuthor

    I believe this would be fixed by @petrochenkov suggestion here where definition of a macro inserts an entry into the macro namespace, although @petrochenkov correct me if I'm wrong!

  2. self-assigned this
    on Jul 10, 2018
  3. petrochenkov commented on Jul 10, 2018

    @petrochenkov
    Contributor

    #[proc_macro_derive(bad)]

    The issue solvable by inserting a dummy entry into macro namespace is not about inert attributes in derives, but about this case.

    macro foo() {} // Should be future-proofed and report an error
    
    #[proc_macro]
    fn foo(...) -> ... { ... }
  4. petrochenkov commented on Jul 10, 2018

    @petrochenkov
    Contributor

    Stabilization PR for proc macro definitions is in process of merge (#52081), so this should be fixed soon too.

  5. petrochenkov commented on Jul 12, 2018

    @petrochenkov
    Contributor

    Fixed locally, will submit a PR today.

  6. added a commit that references this issue on Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions