diff --git a/clippy_lints/src/functions.rs b/clippy_lints/src/functions.rs index 59a16c36d909..e92f077b46bd 100644 --- a/clippy_lints/src/functions.rs +++ b/clippy_lints/src/functions.rs @@ -254,16 +254,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions { if let Some(attr) = attr { let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr); - } else if cx.access_levels.is_exported(item.hir_id) && !is_proc_macro(&item.attrs) { - check_must_use_candidate( - cx, - &sig.decl, - cx.tcx.hir().body(*body_id), - item.span, - item.hir_id, - item.span.with_hi(sig.decl.output.span().hi()), - "this method could have a `#[must_use]` attribute", - ); } } } diff --git a/tests/ui/must_use_candidates.fixed b/tests/ui/must_use_candidates.fixed index dded5321af83..635a265f58b6 100644 --- a/tests/ui/must_use_candidates.fixed +++ b/tests/ui/must_use_candidates.fixed @@ -14,7 +14,7 @@ pub struct MyPure; } impl MyPure { - #[must_use] pub fn inherent_pure(&self) -> u8 { + pub fn inherent_pure(&self) -> u8 { 0 } } @@ -28,7 +28,7 @@ pub trait MyPureTrait { } impl MyPureTrait for MyPure { - #[must_use] fn trait_impl_pure(&self, i: u32) -> u32 { + fn trait_impl_pure(&self, i: u32) -> u32 { i } } diff --git a/tests/ui/must_use_candidates.stderr b/tests/ui/must_use_candidates.stderr index f3a442102373..f504aaf34e39 100644 --- a/tests/ui/must_use_candidates.stderr +++ b/tests/ui/must_use_candidates.stderr @@ -6,18 +6,6 @@ LL | pub fn pure(i: u8) -> u8 { | = note: `-D clippy::must-use-candidate` implied by `-D warnings` -error: this method could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:17:5 - | -LL | pub fn inherent_pure(&self) -> u8 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8` - -error: this method could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:31:5 - | -LL | fn trait_impl_pure(&self, i: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] fn trait_impl_pure(&self, i: u32) -> u32` - error: this function could have a `#[must_use]` attribute --> $DIR/must_use_candidates.rs:48:1 | @@ -36,5 +24,5 @@ error: this function could have a `#[must_use]` attribute LL | pub fn arcd(_x: Arc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc) -> bool` -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors