|
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_expand::base::resolve_path;
|
@@ -899,68 +898,6 @@ impl CheckAttrVisitor<'_> {
|
899 | 898 | }
|
900 | 899 | }
|
901 | 900 |
|
902 |
| - /// Checks `#[doc(hidden)]` attributes. Returns `true` if valid. |
903 |
| - fn check_doc_hidden( |
904 |
| - &self, |
905 |
| - attr: &Attribute, |
906 |
| - meta_index: usize, |
907 |
| - meta: &NestedMetaItem, |
908 |
| - hir_id: HirId, |
909 |
| - target: Target, |
910 |
| - ) -> bool { |
911 |
| - if let Target::AssocConst |
912 |
| - | Target::AssocTy |
913 |
| - | Target::Method(MethodKind::Trait { body: true }) = target |
914 |
| - { |
915 |
| - let parent_hir_id = self.tcx.hir().get_parent_item(hir_id); |
916 |
| - let containing_item = self.tcx.hir().expect_item(parent_hir_id); |
917 |
| - |
918 |
| - if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = containing_item.kind { |
919 |
| - let meta_items = attr.meta_item_list().unwrap(); |
920 |
| - |
921 |
| - let (span, replacement_span) = if meta_items.len() == 1 { |
922 |
| - (attr.span, attr.span) |
923 |
| - } else { |
924 |
| - let meta_span = meta.span(); |
925 |
| - ( |
926 |
| - meta_span, |
927 |
| - meta_span.until(match meta_items.get(meta_index + 1) { |
928 |
| - Some(next_item) => next_item.span(), |
929 |
| - None => match attr.get_normal_item().args { |
930 |
| - MacArgs::Delimited(DelimSpan { close, .. }, ..) => close, |
931 |
| - _ => unreachable!(), |
932 |
| - }, |
933 |
| - }), |
934 |
| - ) |
935 |
| - }; |
936 |
| - |
937 |
| - // FIXME: #[doc(hidden)] was previously erroneously allowed on trait impl items, |
938 |
| - // so for backward compatibility only emit a warning and do not mark it as invalid. |
939 |
| - self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, span, |lint| { |
940 |
| - lint.build("`#[doc(hidden)]` is ignored on trait impl items") |
941 |
| - .warn( |
942 |
| - "this was previously accepted by the compiler but is \ |
943 |
| - being phased out; it will become a hard error in \ |
944 |
| - a future release!", |
945 |
| - ) |
946 |
| - .note( |
947 |
| - "whether the impl item is `doc(hidden)` or not \ |
948 |
| - entirely depends on the corresponding trait item", |
949 |
| - ) |
950 |
| - .span_suggestion( |
951 |
| - replacement_span, |
952 |
| - "remove this attribute", |
953 |
| - "", |
954 |
| - Applicability::MachineApplicable, |
955 |
| - ) |
956 |
| - .emit(); |
957 |
| - }); |
958 |
| - } |
959 |
| - } |
960 |
| - |
961 |
| - true |
962 |
| - } |
963 |
| - |
964 | 901 | /// Checks that an attribute is *not* used at the crate level. Returns `true` if valid.
|
965 | 902 | fn check_attr_not_crate_level(
|
966 | 903 | &self,
|
@@ -1079,7 +1016,7 @@ impl CheckAttrVisitor<'_> {
|
1079 | 1016 | let mut is_valid = true;
|
1080 | 1017 |
|
1081 | 1018 | if let Some(mi) = attr.meta() && let Some(list) = mi.meta_item_list() {
|
1082 |
| - for (meta_index, meta) in list.into_iter().enumerate() { |
| 1019 | + for meta in list { |
1083 | 1020 | if let Some(i_meta) = meta.meta_item() {
|
1084 | 1021 | match i_meta.name_or_empty() {
|
1085 | 1022 | sym::alias
|
@@ -1127,15 +1064,6 @@ impl CheckAttrVisitor<'_> {
|
1127 | 1064 | is_valid = false;
|
1128 | 1065 | }
|
1129 | 1066 |
|
1130 |
| - sym::hidden if !self.check_doc_hidden(attr, |
1131 |
| - meta_index, |
1132 |
| - meta, |
1133 |
| - hir_id, |
1134 |
| - target, |
1135 |
| - ) => { |
1136 |
| - is_valid = false; |
1137 |
| - } |
1138 |
| - |
1139 | 1067 | // no_default_passes: deprecated
|
1140 | 1068 | // passes: deprecated
|
1141 | 1069 | // plugins: removed, but rustdoc warns about it itself
|
|
0 commit comments