Skip to content

Instantly share code, notes, and snippets.

@jyn514
Last active August 29, 2020 13:46
Show Gist options
  • Save jyn514/c47dd32d9671ddf3cf3ac8bca8d68c6d to your computer and use it in GitHub Desktop.
Save jyn514/c47dd32d9671ddf3cf3ac8bca8d68c6d to your computer and use it in GitHub Desktop.

A builtin-macro was attempted to be registered twice.

Erroneous code example:

#![feature(decl_macro)]
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
pub macro test($item:item) {
    /* compiler built-in */
}

mod inner {
       #[rustc_builtin_macro]
       pub macro test($item:item) {
       /* compiler built-in */
       }
}

To fix the issue, remove the duplicate declaration:

#![feature(decl_macro)]
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
pub macro test($item:item) {
    /* compiler built-in */
}

In very rare edge cases, this may happen when loading core or std twice, once with check metadata and once with build metadata. For more information, see #75176.

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