Skip to content

Commit

Permalink
no more must-use-candidate impls
Browse files Browse the repository at this point in the history
  • Loading branch information
llogiq committed Nov 8, 2019
1 parent 4192dbe commit a9bf329
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
10 changes: 0 additions & 10 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/must_use_candidates.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct MyPure;
}

impl MyPure {
#[must_use] pub fn inherent_pure(&self) -> u8 {
pub fn inherent_pure(&self) -> u8 {
0
}
}
Expand All @@ -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
}
}
Expand Down
14 changes: 1 addition & 13 deletions tests/ui/must_use_candidates.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
|
Expand All @@ -36,5 +24,5 @@ error: this function could have a `#[must_use]` attribute
LL | pub fn arcd(_x: Arc<u32>) -> bool {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc<u32>) -> bool`

error: aborting due to 6 previous errors
error: aborting due to 4 previous errors

0 comments on commit a9bf329

Please sign in to comment.