Skip to content

Commit 67508f3

Browse files
committed
Remove #[doc(hidden)] logic from unused_attributes lint
1 parent abace0a commit 67508f3

File tree

4 files changed

+2
-251
lines changed

4 files changed

+2
-251
lines changed

compiler/rustc_passes/src/check_attr.rs

+2-74
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
//! conflicts between multiple such attributes attached to the same
55
//! item.
66
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};
98
use rustc_data_structures::fx::FxHashMap;
109
use rustc_errors::{pluralize, struct_span_err, Applicability, MultiSpan};
1110
use rustc_expand::base::resolve_path;
@@ -899,68 +898,6 @@ impl CheckAttrVisitor<'_> {
899898
}
900899
}
901900

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-
964901
/// Checks that an attribute is *not* used at the crate level. Returns `true` if valid.
965902
fn check_attr_not_crate_level(
966903
&self,
@@ -1079,7 +1016,7 @@ impl CheckAttrVisitor<'_> {
10791016
let mut is_valid = true;
10801017

10811018
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 {
10831020
if let Some(i_meta) = meta.meta_item() {
10841021
match i_meta.name_or_empty() {
10851022
sym::alias
@@ -1127,15 +1064,6 @@ impl CheckAttrVisitor<'_> {
11271064
is_valid = false;
11281065
}
11291066

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-
11391067
// no_default_passes: deprecated
11401068
// passes: deprecated
11411069
// plugins: removed, but rustdoc warns about it itself

src/test/ui/lint/unused/unused-attr-doc-hidden.fixed

-55
This file was deleted.

src/test/ui/lint/unused/unused-attr-doc-hidden.rs

-55
This file was deleted.

src/test/ui/lint/unused/unused-attr-doc-hidden.stderr

-67
This file was deleted.

0 commit comments

Comments
 (0)