Skip to content

Bad error message when using attributes proc_macro #52469

Closed

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

Activity

  1. alexcrichton commented on Jul 17, 2018

    @alexcrichton
    Member

    I believe this is largely fixed with #52458, and the remaining pieces will be fixed by #50911

  2. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    on Jul 17, 2018
  3. arcriley commented on Jul 18, 2018

    @arcriley

    Is there a way to roll back to a previous nightly?

  4. SimonSapin commented on Jul 18, 2018

    @SimonSapin
    ContributorAuthor

    @arcriley You can run rustup install nightly-2018-07-15 and cargo +nightly-2018-07-15 build, for example. Or use a directory override or a toolchain file: https://github.com/rust-lang-nursery/rustup.rs/#toolchain-specification

  5. dominikwerder commented on Jul 18, 2018

    @dominikwerder

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

    Thank you @SimonSapin

  6. steveklabnik commented on Sep 17, 2019

    @steveklabnik
    Contributor

    Both PRs that were said to fix this have been closed; given that this issue is over a year old, and that it's going to be hard to reproduce, I'm going to give this a close. @SimonSapin if you have a way to reproduce this today, let me know and we can re-open!

  7. SimonSapin commented on Sep 17, 2019

    @SimonSapin
    ContributorAuthor

    The correct fix is to add #![feature(use_extern_macros)]

    I suspect that other things have been stabilized in the meantime and this is no longer relevant.

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

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