Skip to content

Commit 0cbc3f2

Browse files
Implement check_attr
1 parent 2ca1fd8 commit 0cbc3f2

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

compiler/rustc_passes/src/check_attr.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
120120
for attr in attrs {
121121
let mut style = None;
122122
match attr {
123+
Attribute::Parsed(AttributeKind::ProcMacro(_)) => {
124+
self.check_proc_macro(hir_id, target, ProcMacroKind::FunctionLike)
125+
}
126+
Attribute::Parsed(AttributeKind::ProcMacroAttribute(_)) => {
127+
self.check_proc_macro(hir_id, target, ProcMacroKind::Attribute);
128+
}
129+
Attribute::Parsed(AttributeKind::ProcMacroDerive { span: attr_span, .. }) => {
130+
self.check_generic_attr(
131+
hir_id,
132+
sym::proc_macro_derive,
133+
*attr_span,
134+
target,
135+
Target::Fn,
136+
);
137+
self.check_proc_macro(hir_id, target, ProcMacroKind::Derive)
138+
}
123139
Attribute::Parsed(AttributeKind::SkipDuringMethodDispatch {
124140
span: attr_span,
125141
..
@@ -207,7 +223,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
207223
Attribute::Parsed(
208224
AttributeKind::BodyStability { .. }
209225
| AttributeKind::ConstStabilityIndirect
210-
| AttributeKind::MacroTransparency(_),
226+
| AttributeKind::MacroTransparency(_)
227+
| AttributeKind::RustcBuiltinMacro { .. },
211228
) => { /* do nothing */ }
212229
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
213230
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)
@@ -315,16 +332,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
315332
[sym::automatically_derived, ..] => {
316333
self.check_generic_attr_unparsed(hir_id, attr, target, Target::Impl)
317334
}
318-
[sym::proc_macro, ..] => {
319-
self.check_proc_macro(hir_id, target, ProcMacroKind::FunctionLike)
320-
}
321-
[sym::proc_macro_attribute, ..] => {
322-
self.check_proc_macro(hir_id, target, ProcMacroKind::Attribute);
323-
}
324-
[sym::proc_macro_derive, ..] => {
325-
self.check_generic_attr_unparsed(hir_id, attr, target, Target::Fn);
326-
self.check_proc_macro(hir_id, target, ProcMacroKind::Derive)
327-
}
328335
[sym::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => {
329336
self.check_autodiff(hir_id, attr, span, target)
330337
}

0 commit comments

Comments
 (0)