diff options
| author | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-08-05 18:11:08 +0200 |
|---|---|---|
| committer | LeSeulArtichaut <leseulartichaut@gmail.com> | 2021-08-05 18:11:08 +0200 |
| commit | ccb5d73dec8b7de2bb5a1bb8be7de59fa1863005 (patch) | |
| tree | b09f56aa0ea7482a3fdbd1f8f47d12d2af8c0654 /clippy_lints | |
| parent | 2dbf0c138de34d7805b9291705f2e2361324f219 (diff) | |
| download | rust-ccb5d73dec8b7de2bb5a1bb8be7de59fa1863005.tar.gz rust-ccb5d73dec8b7de2bb5a1bb8be7de59fa1863005.zip | |
Properly handle `Self` type for `trivially_copy_pass_by_ref`
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/pass_by_ref_or_value.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/pass_by_ref_or_value.rs b/clippy_lints/src/pass_by_ref_or_value.rs index f738ac25417..291e57aabe8 100644 --- a/clippy_lints/src/pass_by_ref_or_value.rs +++ b/clippy_lints/src/pass_by_ref_or_value.rs @@ -2,9 +2,9 @@ use std::cmp; use std::iter; use clippy_utils::diagnostics::span_lint_and_sugg; -use clippy_utils::is_self_ty; use clippy_utils::source::snippet; use clippy_utils::ty::is_copy; +use clippy_utils::{is_self, is_self_ty}; use if_chain::if_chain; use rustc_ast::attr; use rustc_errors::Applicability; @@ -170,7 +170,7 @@ impl<'tcx> PassByRefOrValue { if size <= self.ref_min_size; if let hir::TyKind::Rptr(_, MutTy { ty: decl_ty, .. }) = input.kind; then { - let value_type = if is_self_ty(decl_ty) { + let value_type = if fn_body.and_then(|body| body.params.get(index)).map_or(false, is_self) { "self".into() } else { snippet(cx, decl_ty.span, "_").into() |
