Skip to content

Commit 4c731c2

Browse files
committed
Inline and remove check_builtin_attribute.
It's small and has a single call site. Also change the second `parse_meta` call to use a simple `match`, like the first `parse_meta` call, instead of a confusing `map_err`+`ok` combination.
1 parent 13f2bc9 commit 4c731c2

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

compiler/rustc_parse/src/validate_attr.rs

+11-19
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
2525
match attr_info {
2626
// `rustc_dummy` doesn't have any restrictions specific to built-in attributes.
2727
Some(BuiltinAttribute { name, template, .. }) if *name != sym::rustc_dummy => {
28-
check_builtin_attribute(psess, attr, *name, *template)
28+
match parse_meta(psess, attr) {
29+
Ok(meta) => check_builtin_meta_item(psess, &meta, attr.style, *name, *template),
30+
Err(err) => {
31+
err.emit();
32+
}
33+
}
2934
}
3035
_ if let AttrArgs::Eq(..) = attr.get_normal_item().args => {
3136
// All key-value attributes are restricted to meta-item syntax.
32-
parse_meta(psess, attr)
33-
.map_err(|err| {
37+
match parse_meta(psess, attr) {
38+
Ok(_) => {}
39+
Err(err) => {
3440
err.emit();
35-
})
36-
.ok();
41+
}
42+
}
3743
}
3844
_ => {}
3945
}
@@ -133,20 +139,6 @@ fn is_attr_template_compatible(template: &AttributeTemplate, meta: &ast::MetaIte
133139
}
134140
}
135141

136-
fn check_builtin_attribute(
137-
psess: &ParseSess,
138-
attr: &Attribute,
139-
name: Symbol,
140-
template: AttributeTemplate,
141-
) {
142-
match parse_meta(psess, attr) {
143-
Ok(meta) => check_builtin_meta_item(psess, &meta, attr.style, name, template),
144-
Err(err) => {
145-
err.emit();
146-
}
147-
}
148-
}
149-
150142
pub fn check_builtin_meta_item(
151143
psess: &ParseSess,
152144
meta: &MetaItem,

0 commit comments

Comments
 (0)