Skip to content

Commit 0112fc1

Browse files
Move check for new attribute to check_builtin_meta_item
Signed-off-by: Jonathan Brouwer <[email protected]>
1 parent 1ce9c97 commit 0112fc1

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -267,25 +267,10 @@ pub fn check_builtin_meta_item(
267267
deny_unsafety: bool,
268268
) {
269269
if !is_attr_template_compatible(&template, &meta.kind) {
270-
emit_malformed_attribute(psess, style, meta.span, name, template);
271-
}
272-
273-
if deny_unsafety {
274-
deny_builtin_meta_unsafety(psess, meta);
275-
}
276-
}
277-
278-
fn emit_malformed_attribute(
279-
psess: &ParseSess,
280-
style: ast::AttrStyle,
281-
span: Span,
282-
name: Symbol,
283-
template: AttributeTemplate,
284-
) {
285-
// attrs with new parsers are locally validated so excluded here
286-
if matches!(
287-
name,
288-
sym::inline
270+
// attrs with new parsers are locally validated so excluded here
271+
if matches!(
272+
name,
273+
sym::inline
289274
| sym::may_dangle
290275
| sym::rustc_as_ptr
291276
| sym::rustc_pub_transparent
@@ -308,10 +293,24 @@ fn emit_malformed_attribute(
308293
| sym::link_section
309294
| sym::rustc_layout_scalar_valid_range_start
310295
| sym::rustc_layout_scalar_valid_range_end
311-
) {
312-
return;
296+
) {
297+
return;
298+
}
299+
emit_malformed_attribute(psess, style, meta.span, name, template);
300+
}
301+
302+
if deny_unsafety {
303+
deny_builtin_meta_unsafety(psess, meta);
313304
}
305+
}
314306

307+
fn emit_malformed_attribute(
308+
psess: &ParseSess,
309+
style: ast::AttrStyle,
310+
span: Span,
311+
name: Symbol,
312+
template: AttributeTemplate,
313+
) {
315314
// Some of previously accepted forms were used in practice,
316315
// report them as warnings for now.
317316
let should_warn =

0 commit comments

Comments
 (0)