]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/methods/clone_on_copy.rs
add paren before '?' when suggesting deref
[rust.git] / clippy_lints / src / methods / clone_on_copy.rs
index 0b38a07204e86cec08a825a3d00b5e7b3dc09c46..a813d39441b547ffb0aa1e900fd6bcbf4a4697f5 100644 (file)
@@ -4,7 +4,7 @@
 use clippy_utils::sugg;
 use clippy_utils::ty::is_copy;
 use rustc_errors::Applicability;
-use rustc_hir::{BindingAnnotation, Expr, ExprKind, MatchSource, Node, PatKind};
+use rustc_hir::{BindingAnnotation, Expr, ExprKind, MatchSource, Node, PatKind, QPath};
 use rustc_lint::LateContext;
 use rustc_middle::ty::{self, adjustment::Adjust};
 use rustc_span::symbol::{sym, Symbol};
@@ -86,6 +86,10 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: Symbol,
                 {
                     return;
                 },
+                ExprKind::Call(hir_callee, _) => match hir_callee.kind {
+                    ExprKind::Path(QPath::LangItem(rustc_hir::LangItem::TryTraitBranch, _, _)) => true,
+                    _ => false,
+                },
                 ExprKind::MethodCall(_, [self_arg, ..], _) if expr.hir_id == self_arg.hir_id => true,
                 ExprKind::Match(_, _, MatchSource::TryDesugar | MatchSource::AwaitDesugar)
                 | ExprKind::Field(..)