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

Putting #[derive] before a macro attribute results in a bad error #89227

Closed
meithecatte opened this issue Sep 24, 2021 · 2 comments
Closed

Putting #[derive] before a macro attribute results in a bad error #89227

meithecatte opened this issue Sep 24, 2021 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@meithecatte
Copy link
Contributor

I don't know, off the top of my head, what attribute macros are available on the playground, so I'll use the crate I'm maintaining. The details of it are pretty much irrelevant anyway.

Given the following code:

#[derive(Copy, Clone)]
#[enumflags2::bitflags]
#[repr(u8)]
enum Foo {
    A = 1,
}

fn main() {}

The current output is:

error[E0658]: macro attributes in `#[derive]` output are unstable
 --> src/main.rs:2:3
  |
2 | #[enumflags2::bitflags]
  |   ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #81119 <https://github.com/rust-lang/rust/issues/81119> for more information
  = help: add `#![feature(macro_attributes_in_derive_output)]` to the crate attributes to enable

A few versions back (I've tested 1.41.1), we were outputting the following, much more legible error:

error: macro attributes must be placed before `#[derive]`
 --> src/main.rs:2:1
  |
2 | #[enumflags2::bitflags]
  | ^^^^^^^^^^^^^^^^^^^^^^^

This is motivated by meithecatte/enumflags2#37 — it took me a moment to understand what was happening when a user reported that error.

@meithecatte meithecatte added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 24, 2021
@petrochenkov
Copy link
Contributor

This is going to be stabilized by #87220 very soon.

@meithecatte
Copy link
Contributor Author

Ah, so in that case the code will just start working? Great! I don't think any action is necessary here, then.

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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants