Rollup merge of #97208 - fmease:fix-issue-97205, r=oli-obk
Do not emit the lint `unused_attributes` for *inherent* `#[doc(hidden)]` associated items Fixes #97205 (embarrassing oversight from #96008). `@rustbot` label A-lint
This commit is contained in:
commit
2941434d1b
@ -832,7 +832,7 @@ fn check_doc_hidden(
|
|||||||
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
let parent_hir_id = self.tcx.hir().get_parent_item(hir_id);
|
||||||
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
|
let containing_item = self.tcx.hir().expect_item(parent_hir_id);
|
||||||
|
|
||||||
if Target::from_item(containing_item) == Target::Impl {
|
if let hir::ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = containing_item.kind {
|
||||||
let meta_items = attr.meta_item_list().unwrap();
|
let meta_items = attr.meta_item_list().unwrap();
|
||||||
|
|
||||||
let (span, replacement_span) = if meta_items.len() == 1 {
|
let (span, replacement_span) = if meta_items.len() == 1 {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#![deny(unused_attributes)]
|
#![feature(inherent_associated_types)]
|
||||||
|
#![allow(dead_code, incomplete_features)]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
#![deny(unused_attributes)]
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
@ -12,6 +14,17 @@ pub trait Trait {
|
|||||||
|
|
||||||
pub struct Implementor;
|
pub struct Implementor;
|
||||||
|
|
||||||
|
impl Implementor {
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
type Inh = ();
|
||||||
|
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
const INH: () = ();
|
||||||
|
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
fn inh() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl Trait for Implementor {
|
impl Trait for Implementor {
|
||||||
|
|
||||||
type It = ();
|
type It = ();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#![deny(unused_attributes)]
|
#![feature(inherent_associated_types)]
|
||||||
|
#![allow(dead_code, incomplete_features)]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
#![deny(unused_attributes)]
|
||||||
// run-rustfix
|
// run-rustfix
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
@ -12,6 +14,17 @@ pub trait Trait {
|
|||||||
|
|
||||||
pub struct Implementor;
|
pub struct Implementor;
|
||||||
|
|
||||||
|
impl Implementor {
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
type Inh = ();
|
||||||
|
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
const INH: () = ();
|
||||||
|
|
||||||
|
#[doc(hidden)] // no error
|
||||||
|
fn inh() {}
|
||||||
|
}
|
||||||
|
|
||||||
impl Trait for Implementor {
|
impl Trait for Implementor {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
type It = ();
|
type It = ();
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:16:5
|
--> $DIR/unused-attr-doc-hidden.rs:29:5
|
||||||
|
|
|
|
||||||
LL | #[doc(hidden)]
|
LL | #[doc(hidden)]
|
||||||
| ^^^^^^^^^^^^^^ help: remove this attribute
|
| ^^^^^^^^^^^^^^ help: remove this attribute
|
||||||
|
|
|
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:1:9
|
--> $DIR/unused-attr-doc-hidden.rs:4:9
|
||||||
|
|
|
|
||||||
LL | #![deny(unused_attributes)]
|
LL | #![deny(unused_attributes)]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
@ -13,7 +13,7 @@ LL | #![deny(unused_attributes)]
|
|||||||
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
||||||
|
|
||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:21:5
|
--> $DIR/unused-attr-doc-hidden.rs:34:5
|
||||||
|
|
|
|
||||||
LL | #[doc(hidden)]
|
LL | #[doc(hidden)]
|
||||||
| ^^^^^^^^^^^^^^ help: remove this attribute
|
| ^^^^^^^^^^^^^^ help: remove this attribute
|
||||||
@ -22,7 +22,7 @@ LL | #[doc(hidden)]
|
|||||||
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
||||||
|
|
||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:26:11
|
--> $DIR/unused-attr-doc-hidden.rs:39:11
|
||||||
|
|
|
|
||||||
LL | #[doc(hidden, alias = "aka")]
|
LL | #[doc(hidden, alias = "aka")]
|
||||||
| ^^^^^^--
|
| ^^^^^^--
|
||||||
@ -33,7 +33,7 @@ LL | #[doc(hidden, alias = "aka")]
|
|||||||
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
||||||
|
|
||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:31:27
|
--> $DIR/unused-attr-doc-hidden.rs:44:27
|
||||||
|
|
|
|
||||||
LL | #[doc(alias = "this", hidden,)]
|
LL | #[doc(alias = "this", hidden,)]
|
||||||
| ^^^^^^-
|
| ^^^^^^-
|
||||||
@ -44,7 +44,7 @@ LL | #[doc(alias = "this", hidden,)]
|
|||||||
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
||||||
|
|
||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:36:11
|
--> $DIR/unused-attr-doc-hidden.rs:49:11
|
||||||
|
|
|
|
||||||
LL | #[doc(hidden, hidden)]
|
LL | #[doc(hidden, hidden)]
|
||||||
| ^^^^^^--
|
| ^^^^^^--
|
||||||
@ -55,7 +55,7 @@ LL | #[doc(hidden, hidden)]
|
|||||||
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
= note: whether the impl item is `doc(hidden)` or not entirely depends on the corresponding trait item
|
||||||
|
|
||||||
error: `#[doc(hidden)]` is ignored on trait impl items
|
error: `#[doc(hidden)]` is ignored on trait impl items
|
||||||
--> $DIR/unused-attr-doc-hidden.rs:36:19
|
--> $DIR/unused-attr-doc-hidden.rs:49:19
|
||||||
|
|
|
|
||||||
LL | #[doc(hidden, hidden)]
|
LL | #[doc(hidden, hidden)]
|
||||||
| ^^^^^^ help: remove this attribute
|
| ^^^^^^ help: remove this attribute
|
||||||
|
Loading…
Reference in New Issue
Block a user