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

Custom attribute used on thing disallowing custom attributes should say that #53573

Open
Havvy opened this issue Aug 21, 2018 · 2 comments
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Havvy
Copy link
Contributor

Havvy commented Aug 21, 2018

crate: custom_attr

extern crate proc_macro;
use proc_macro::TokenStream;

#[proc_macro_attribute]
pub fn custom(_attr: TokenStream, item: TokenStream) -> TokenStream {
    item
}

crate: not the previous one

extern crate custom_attr;
use custom_attr::custom;

fn main() {
   match () {
        #[custom]
        () => {}
    }
}

Current Error

error[E0658]: The attribute `custom` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
  --> src/main.rs:LL:L
   |
L |         #[custom]
   |         ^^^^^^^^
   |
   = help: add #![feature(custom_attribute)] to the crate attributes to enable

Wanted Error

error[E0NNN]: Custom attributes can only be applied to items
  --> src/main.rs:LL:L
   |
L |         #[custom]
   |         ^^^^^^^^
   |

(I'm assuming they can only be applied to items in nightly without using feature flags in Rust today. It'd be nice to get that assumption confirmed as well)

@Havvy Havvy added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 21, 2018
@eddyb
Copy link
Member

eddyb commented Aug 22, 2018

cc @petrochenkov

@petrochenkov
Copy link
Contributor

This is item 4 in #50911 (comment) more or less.

@crlf0710 crlf0710 added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 11, 2020
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

4 participants