Skip to content

Can't use a custom proc_macro_attribute at crate root #42699

Closed
@DanielShaulov

Description

@DanielShaulov

I have a proc-macro crate mycrate, that defines a #[proc_macro_attribute] function mymacro.
There is no way to use it (that I could find) at crate root level

I tried this code:

#![feature(proc_macro)]
extern crate mycrate;
#![mycrate::mymacro]

And I get the following error:
error: an inner attribute is not permitted in this context
As I understand this is because I use it after the extern crate, but it won't resolve before it.

(I know this feature is not stable yet, just want to know if there is a plan/workaround for this)

Meta

rustc --version --verbose:

rustc 1.19.0-nightly (554c685b0 2017-06-14)
binary: rustc
commit-hash: 554c685b0b3b25b7aa752717edf50b8d6bcab7a0
commit-date: 2017-06-14
host: x86_64-pc-windows-msvc
release: 1.19.0-nightly
LLVM version: 4.0

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