Skip to content

Bad error message when using attributes proc_macro #52469

Closed
@SimonSapin

Description

@SimonSapin

Upgrading Servo to today’s Nightly caused a confusing pair of error messages:

error[E0432]: unresolved import `dom_struct::dom_struct`
  --> components/script/dom/htmlulistelement.rs:10:5
   |
10 | use dom_struct::dom_struct;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `dom_struct` in the root

error[E0658]: The attribute `dom_struct` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> components/script/dom/bluetoothpermissionresult.rs:26:1
   |
26 | #[dom_struct]
   | ^^^^^^^^^^^^^
   |
   = help: add #![feature(custom_attribute)] to the crate attributes to enable

Adding #[macro_use] changes the second error to:

error[E0658]: attribute procedural macros are experimental (see issue #38356)
  --> components/script/dom/attr.rs:28:1
   |
28 | #[dom_struct]
   | ^^^^^^^^^^^^^
   | 
  ::: components/script/lib.rs:35:1
   |
35 | #[macro_use] extern crate dom_struct;
   | ------------ procedural macro imported here
   |
   = help: add #![feature(proc_macro)] to the crate attributes to enable

All three messages are wrong:

  • dom_struct::dom_struct does exist
  • feature(custom_attribute) is not the correct fix
  • feature(proc_macro) is not only not the correct fix, it was already present!

The correct fix is to add #![feature(use_extern_macros)], but the only way to figure that out is to read #52081.

CC @alexcrichton

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions