Rollup merge of #152577 - Ozzy1423:macro-attr, r=JonathanBrouwer
Port #[rustc_proc_macro_decls] to the new attribute parser. Tracking issue: https://github.com/rust-lang/rust/issues/131229 r? @JonathanBrouwer
This commit is contained in:
commit
cf0cb74612
6 changed files with 18 additions and 5 deletions
|
|
@ -206,3 +206,12 @@ impl<S: Stage> SingleAttributeParser<S> for CollapseDebugInfoParser {
|
|||
Some(AttributeKind::CollapseDebugInfo(info))
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RustcProcMacroDeclsParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcProcMacroDeclsParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_proc_macro_decls];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Static)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcProcMacroDecls;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<RustcOutlivesParser>>,
|
||||
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
|
||||
Single<WithoutArgs<RustcPreserveUbChecksParser>>,
|
||||
Single<WithoutArgs<RustcProcMacroDeclsParser>>,
|
||||
Single<WithoutArgs<RustcReallocatorParser>>,
|
||||
Single<WithoutArgs<RustcRegionsParser>>,
|
||||
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
|
||||
|
|
|
|||
|
|
@ -1295,6 +1295,9 @@ pub enum AttributeKind {
|
|||
/// Represents `#[rustc_preserve_ub_checks]`
|
||||
RustcPreserveUbChecks,
|
||||
|
||||
/// Represents `#[rustc_proc_macro_decls]`
|
||||
RustcProcMacroDecls,
|
||||
|
||||
/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
|
||||
RustcPubTransparent(Span),
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ impl AttributeKind {
|
|||
RustcPassByValue(..) => Yes,
|
||||
RustcPassIndirectlyInNonRusticAbis(..) => No,
|
||||
RustcPreserveUbChecks => No,
|
||||
RustcProcMacroDecls => No,
|
||||
RustcPubTransparent(..) => Yes,
|
||||
RustcReallocator => No,
|
||||
RustcRegions => No,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
use rustc_ast::attr;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_hir::find_attr;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::sym;
|
||||
|
||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||
let mut decls = None;
|
||||
|
||||
for id in tcx.hir_free_items() {
|
||||
let attrs = tcx.hir_attrs(id.hir_id());
|
||||
if attr::contains_name(attrs, sym::rustc_proc_macro_decls) {
|
||||
if find_attr!(tcx.hir_attrs(id.hir_id()), AttributeKind::RustcProcMacroDecls) {
|
||||
decls = Some(id.owner_id.def_id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -350,6 +350,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcPassByValue (..)
|
||||
| AttributeKind::RustcPassIndirectlyInNonRusticAbis(..)
|
||||
| AttributeKind::RustcPreserveUbChecks
|
||||
| AttributeKind::RustcProcMacroDecls
|
||||
| AttributeKind::RustcReallocator
|
||||
| AttributeKind::RustcRegions
|
||||
| AttributeKind::RustcReservationImpl(..)
|
||||
|
|
@ -403,7 +404,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| sym::rustc_doc_primitive
|
||||
| sym::rustc_test_marker
|
||||
| sym::rustc_layout
|
||||
| sym::rustc_proc_macro_decls
|
||||
| sym::rustc_autodiff
|
||||
| sym::rustc_capture_analysis
|
||||
| sym::rustc_mir
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue