|
4 | 4 | //! conflicts between multiple such attributes attached to the same
|
5 | 5 | //! item.
|
6 | 6 |
|
7 |
| -use rustc_ast::tokenstream::DelimSpan; |
8 |
| -use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MacArgs, MetaItemKind, NestedMetaItem}; |
| 7 | +use rustc_ast::{ast, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; |
9 | 8 | use rustc_data_structures::fx::FxHashMap;
|
10 | 9 | use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
|
11 | 10 | use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTIN_ATTRIBUTE_MAP};
|
@@ -815,68 +814,6 @@ impl CheckAttrVisitor<'_> {
|
815 | 814 | }
|
816 | 815 | }
|
817 | 816 |
|
818 |
| - /// Checks `#[doc(hidden)]` attributes. Returns `true` if valid. |
819 |
| - fn check_doc_hidden( |
820 |
| - &self, |
821 |
| - attr: &Attribute, |
822 |
| - meta_index: usize, |
823 |
| - meta: &NestedMetaItem, |
824 |
| - hir_id: HirId, |
825 |
| - target: Target, |
826 |
| - ) -> bool { |
827 |
| - if let Target::AssocConst |
828 |
| - | Target::AssocTy |
829 |
| - | Target::Method(MethodKind::Trait { body: true }) = target |
830 |
| - { |
831 |
| - let parent_hir_id = self.tcx.hir().get_parent_item(hir_id); |
832 |
| - let containing_item = self.tcx.hir().expect_item(parent_hir_id); |
833 |
| - |
834 |
| - if Target::from_item(containing_item) == Target::Impl { |
835 |
| - let meta_items = attr.meta_item_list().unwrap(); |
836 |
| - |
837 |
| - let (span, replacement_span) = if meta_items.len() == 1 { |
838 |
| - (attr.span, attr.span) |
839 |
| - } else { |
840 |
| - let meta_span = meta.span(); |
841 |
| - ( |
842 |
| - meta_span, |
843 |
| - meta_span.until(match meta_items.get(meta_index + 1) { |
844 |
| - Some(next_item) => next_item.span(), |
845 |
| - None => match attr.get_normal_item().args { |
846 |
| - MacArgs::Delimited(DelimSpan { close, .. }, ..) => close, |
847 |
| - _ => unreachable!(), |
848 |
| - }, |
849 |
| - }), |
850 |
| - ) |
851 |
| - }; |
852 |
| - |
853 |
| - // FIXME: #[doc(hidden)] was previously erroneously allowed on trait impl items, |
854 |
| - // so for backward compatibility only emit a warning and do not mark it as invalid. |
855 |
| - self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, span, |lint| { |
856 |
| - lint.build("`#[doc(hidden)]` is ignored on trait impl items") |
857 |
| - .warn( |
858 |
| - "this was previously accepted by the compiler but is \ |
859 |
| - being phased out; it will become a hard error in \ |
860 |
| - a future release!", |
861 |
| - ) |
862 |
| - .note( |
863 |
| - "whether the impl item is `doc(hidden)` or not \ |
864 |
| - entirely depends on the corresponding trait item", |
865 |
| - ) |
866 |
| - .span_suggestion( |
867 |
| - replacement_span, |
868 |
| - "remove this attribute", |
869 |
| - String::new(), |
870 |
| - Applicability::MachineApplicable, |
871 |
| - ) |
872 |
| - .emit(); |
873 |
| - }); |
874 |
| - } |
875 |
| - } |
876 |
| - |
877 |
| - true |
878 |
| - } |
879 |
| - |
880 | 817 | /// Checks that an attribute is *not* used at the crate level. Returns `true` if valid.
|
881 | 818 | fn check_attr_not_crate_level(
|
882 | 819 | &self,
|
@@ -995,7 +932,7 @@ impl CheckAttrVisitor<'_> {
|
995 | 932 | let mut is_valid = true;
|
996 | 933 |
|
997 | 934 | if let Some(mi) = attr.meta() && let Some(list) = mi.meta_item_list() {
|
998 |
| - for (meta_index, meta) in list.into_iter().enumerate() { |
| 935 | + for meta in list { |
999 | 936 | if let Some(i_meta) = meta.meta_item() {
|
1000 | 937 | match i_meta.name_or_empty() {
|
1001 | 938 | sym::alias
|
@@ -1036,15 +973,6 @@ impl CheckAttrVisitor<'_> {
|
1036 | 973 | is_valid = false;
|
1037 | 974 | }
|
1038 | 975 |
|
1039 |
| - sym::hidden if !self.check_doc_hidden(attr, |
1040 |
| - meta_index, |
1041 |
| - meta, |
1042 |
| - hir_id, |
1043 |
| - target, |
1044 |
| - ) => { |
1045 |
| - is_valid = false; |
1046 |
| - } |
1047 |
| - |
1048 | 976 | // no_default_passes: deprecated
|
1049 | 977 | // passes: deprecated
|
1050 | 978 | // plugins: removed, but rustdoc warns about it itself
|
|
0 commit comments