Skip to content

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

Open
@Havvy

Description

@Havvy

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions