diff options
| author | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-07-02 23:07:34 +0200 |
|---|---|---|
| committer | Jonathan Brouwer <jonathantbrouwer@gmail.com> | 2025-07-06 22:18:58 +0200 |
| commit | ef3d7741e5f9e61b50a6023694981c913de54526 (patch) | |
| tree | b426174e57bead9ce567c0e48516c12074ba88ab /compiler/rustc_parse/src/validate_attr.rs | |
| parent | de031bbcb161b0b7fc0eb16f77b02ce9fbdf4c9e (diff) | |
| download | rust-ef3d7741e5f9e61b50a6023694981c913de54526.tar.gz rust-ef3d7741e5f9e61b50a6023694981c913de54526.zip | |
Move check for new attribute to `check_builtin_meta_item`
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Diffstat (limited to 'compiler/rustc_parse/src/validate_attr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/validate_attr.rs | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/compiler/rustc_parse/src/validate_attr.rs b/compiler/rustc_parse/src/validate_attr.rs index 8fdc06ee463..66bf9851f97 100644 --- a/compiler/rustc_parse/src/validate_attr.rs +++ b/compiler/rustc_parse/src/validate_attr.rs @@ -267,6 +267,41 @@ pub fn check_builtin_meta_item( deny_unsafety: bool, ) { if !is_attr_template_compatible(&template, &meta.kind) { + // attrs with new parsers are locally validated so excluded here + if matches!( + name, + sym::inline + | sym::may_dangle + | sym::rustc_as_ptr + | sym::rustc_pub_transparent + | sym::rustc_const_stable_indirect + | sym::rustc_force_inline + | sym::rustc_confusables + | sym::rustc_skip_during_method_dispatch + | sym::rustc_pass_by_value + | sym::repr + | sym::align + | sym::deprecated + | sym::optimize + | sym::cold + | sym::target_feature + | sym::rustc_allow_const_fn_unstable + | sym::naked + | sym::no_mangle + | sym::non_exhaustive + | sym::ignore + | sym::must_use + | sym::track_caller + | sym::link_name + | sym::export_name + | sym::rustc_macro_transparency + | sym::link_section + | sym::rustc_layout_scalar_valid_range_start + | sym::rustc_layout_scalar_valid_range_end + | sym::no_implicit_prelude + ) { + return; + } emit_malformed_attribute(psess, style, meta.span, name, template); } @@ -282,42 +317,6 @@ fn emit_malformed_attribute( name: Symbol, template: AttributeTemplate, ) { - // attrs with new parsers are locally validated so excluded here - if matches!( - name, - sym::inline - | sym::may_dangle - | sym::rustc_as_ptr - | sym::rustc_pub_transparent - | sym::rustc_const_stable_indirect - | sym::rustc_force_inline - | sym::rustc_confusables - | sym::rustc_skip_during_method_dispatch - | sym::rustc_pass_by_value - | sym::repr - | sym::align - | sym::deprecated - | sym::optimize - | sym::cold - | sym::target_feature - | sym::rustc_allow_const_fn_unstable - | sym::naked - | sym::no_mangle - | sym::non_exhaustive - | sym::ignore - | sym::must_use - | sym::track_caller - | sym::link_name - | sym::export_name - | sym::rustc_macro_transparency - | sym::link_section - | sym::rustc_layout_scalar_valid_range_start - | sym::rustc_layout_scalar_valid_range_end - | sym::no_implicit_prelude - ) { - return; - } - // Some of previously accepted forms were used in practice, // report them as warnings for now. let should_warn = |name| matches!(name, sym::doc | sym::link | sym::test | sym::bench); |
