mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
no more must-use-candidate on trait impls
This commit is contained in:
parent
180f87065f
commit
5f0f67375d
3 changed files with 7 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::utils::{
|
||||
attrs::is_proc_macro, iter_input_pats, match_def_path, qpath_res, return_ty, snippet, snippet_opt,
|
||||
span_help_and_lint, span_lint, span_lint_and_then, type_is_unsafe_function,
|
||||
span_help_and_lint, span_lint, span_lint_and_then, trait_ref_of_method, type_is_unsafe_function,
|
||||
};
|
||||
use matches::matches;
|
||||
use rustc::hir::{self, def::Res, def_id::DefId, intravisit};
|
||||
|
@ -254,7 +254,10 @@ 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) {
|
||||
} else if cx.access_levels.is_exported(item.hir_id)
|
||||
&& !is_proc_macro(&item.attrs)
|
||||
&& trait_ref_of_method(cx, item.hir_id).is_none()
|
||||
{
|
||||
check_must_use_candidate(
|
||||
cx,
|
||||
&sig.decl,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,6 @@ error: this method could have a `#[must_use]` attribute
|
|||
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 +30,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 5 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue