What happened to proc_macro_attribute?

My project using proc macro attribute fails to compile after updating to latest nighly Rust. Obviously, something in compiler changed, but errors are misleading.


members = ["foo", "bar"]



#[macro_use] extern crate bar;

use bar::baz;

fn main() {
    println!("Hello, world!");


extern crate proc_macro;

use proc_macro::TokenStream;

pub fn baz(_attr: TokenStream, input: TokenStream) -> TokenStream {


error[E0432]: unresolved import `bar::baz`>                              ] 1/2: rust-procattr
 --> foo/src/main.rs:5:5
5 | use bar::baz;
  |     ^^^^^^^^ no `baz` in the root

error[E0658]: attribute procedural macros are experimental (see issue #38356)
 --> foo/src/main.rs:7:1
3 | #[macro_use] extern crate bar;
  | ------------ procedural macro imported here
7 | #[baz]
  | ^^^^^^
  = help: add #![feature(proc_macro)] to the crate attributes to enable

warning: unused `#[macro_use]` import
 --> foo/src/main.rs:3:1
3 | #[macro_use] extern crate bar;
  | ^^^^^^^^^^^^
  = note: #[warn(unused_imports)] on by default

warning: unused import: `bar::baz`
 --> foo/src/main.rs:5:5
5 | use bar::baz;
  |     ^^^^^^^^

error: aborting due to 2 previous errors

Some errors occurred: E0432, E0658.
For more information about an error, try `rustc --explain E0432`.
error: Could not compile `rust-procattr`.

To learn more, run the command again with --verbose.

How to fix it?

You probably need to add #![feature(use_extern_macros)] to the top of your crate and then manually import the macros you use?

Thanks, it works! Is there single source I may track to know breaking changes in nighly?

To be honest, i stumbled upon this by accident.
This feature switch is actually really old, but it seems only recently enforced by the compiler.

In my opinion macro stabilization is tough to follow currently. You would need to track stabilization changes across the Rust code base AND dependant crates (proc-macro and proc-macro2). This boils down to follow the relevant github issues. The unstable book can act as a starting point, but you won’t discover newly introduced/related feature switches there. 1

In general i’m ok with regular changes to nightly, but these macro changes are driving me crazy. Until the epoch release i’m sticking with declarative macro’s, these are stable.