danielhenrymantilla / macro_rules_attribute-rs

Use declarative macros as proc_macro attributes or derives
https://docs.rs/macro-rules-attribute
Apache License 2.0
102 stars 10 forks source link

Remove through-cargo rename of inner proc-macro crate #2

Closed connorpower closed 3 years ago

connorpower commented 3 years ago

Problem

When cross-compiling and depending on a Cargo-renamed pure proc-macro crate a rustc bug can sometimes be triggered which errors in unresolved imports.

In the case of ::macro_rules_attribute, the bug amounted to the following errors:

error[E0432]: unresolved imports `proc_macro::macro_rules_attribute`, `proc_macro::macro_rules_derive`
  |
8 |     macro_rules_attribute,
  |     ^^^^^^^^^^^^^^^^^^^^^ no `macro_rules_attribute` in the root
9 |     macro_rules_derive,
  |     ^^^^^^^^^^^^^^^^^^ no `macro_rules_derive` in the root

Solution

Undo the renaming at the Cargo.toml layer and instead use the full name in src/lib.rs. This is unfortunate, but the change is at least contained entirely within the crate.

I've confirmed with a Cargo patch that undoing these renames avoids triggering the rustc bug when cross-compiling.