Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad error message when using attributes proc_macro #52469

Closed
SimonSapin opened this issue Jul 17, 2018 · 6 comments
Closed

Bad error message when using attributes proc_macro #52469

SimonSapin opened this issue Jul 17, 2018 · 6 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@SimonSapin
Copy link
Contributor

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

@alexcrichton
Copy link
Member

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

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Jul 17, 2018
@arcriley
Copy link

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

@SimonSapin
Copy link
Contributor Author

@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

@dominikwerder
Copy link

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

@steveklabnik
Copy link
Member

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!

@SimonSapin
Copy link
Contributor Author

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
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

No branches or pull requests

6 participants