|
2 | 2 |
|
3 | 3 | use crate::ast::{self, Attribute, MetaItem, NestedMetaItem}; |
4 | 4 | use crate::early_buffered_lints::BufferedEarlyLintId; |
5 | | -use crate::ext::base::ExtCtxt; |
6 | 5 | use crate::feature_gate::{Features, GatedCfg}; |
7 | 6 | use crate::print::pprust; |
8 | 7 | use crate::sess::ParseSess; |
@@ -32,6 +31,10 @@ pub struct AttributeTemplate { |
32 | 31 | } |
33 | 32 |
|
34 | 33 | impl AttributeTemplate { |
| 34 | + pub fn only_word() -> Self { |
| 35 | + Self { word: true, list: None, name_value_str: None } |
| 36 | + } |
| 37 | + |
35 | 38 | /// Checks that the given meta-item is compatible with this template. |
36 | 39 | fn compatible(&self, meta_item_kind: &ast::MetaItemKind) -> bool { |
37 | 40 | match meta_item_kind { |
@@ -937,14 +940,7 @@ pub fn find_transparency( |
937 | 940 | (transparency.map_or(fallback, |t| t.0), error) |
938 | 941 | } |
939 | 942 |
|
940 | | -pub fn check_builtin_macro_attribute(ecx: &ExtCtxt<'_>, meta_item: &MetaItem, name: Symbol) { |
941 | | - // All the built-in macro attributes are "words" at the moment. |
942 | | - let template = AttributeTemplate { word: true, list: None, name_value_str: None }; |
943 | | - let attr = ecx.attribute(meta_item.clone()); |
944 | | - check_builtin_attribute(ecx.parse_sess, &attr, name, template); |
945 | | -} |
946 | | - |
947 | | -crate fn check_builtin_attribute( |
| 943 | +pub fn check_builtin_attribute( |
948 | 944 | sess: &ParseSess, attr: &ast::Attribute, name: Symbol, template: AttributeTemplate |
949 | 945 | ) { |
950 | 946 | // Some special attributes like `cfg` must be checked |
|
0 commit comments