Avoid unnecessary MetaItem
/Attribute
conversions.
`check_builtin_attribute` calls `parse_meta` to convert an `Attribute` to a `MetaItem`, which it then checks. However, many callers of `check_builtin_attribute` start with a `MetaItem`, and then convert it to an `Attribute` by calling `cx.attribute(meta_item)`. This `MetaItem` to `Attribute` to `MetaItem` conversion is silly. This commit adds a new function `check_builtin_meta_item`, which can be called instead from these call sites. `check_builtin_attribute` also now calls it. The commit also renames `check_meta` as `check_attr` to better match its arguments.
This commit is contained in:
parent
2585bcea0b
commit
c9ae38c71e
6 changed files with 44 additions and 29 deletions
|
@ -912,7 +912,7 @@ fn validate_generic_param_order(
|
|||
|
||||
impl<'a> Visitor<'a> for AstValidator<'a> {
|
||||
fn visit_attribute(&mut self, attr: &Attribute) {
|
||||
validate_attr::check_meta(&self.session.parse_sess, attr);
|
||||
validate_attr::check_attr(&self.session.parse_sess, attr);
|
||||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue