|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then; |
| 2 | +use clippy_utils::is_from_proc_macro; |
2 | 3 | use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; |
3 | | -use clippy_utils::{is_from_proc_macro, last_path_segment}; |
4 | | -use rustc_hir::{Expr, ExprKind}; |
| 4 | +use rustc_hir::{Expr, ExprKind, QPath}; |
5 | 5 | use rustc_lint::{LateContext, LateLintPass}; |
6 | 6 | use rustc_middle::ty; |
7 | 7 | use rustc_middle::ty::print::with_forced_trimmed_paths; |
@@ -42,12 +42,11 @@ declare_lint_pass!(ArcWithNonSendSync => [ARC_WITH_NON_SEND_SYNC]); |
42 | 42 |
|
43 | 43 | impl<'tcx> LateLintPass<'tcx> for ArcWithNonSendSync { |
44 | 44 | fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { |
45 | | - if !expr.span.from_expansion() |
46 | | - && let ty = cx.typeck_results().expr_ty(expr) |
47 | | - && is_type_diagnostic_item(cx, ty, sym::Arc) |
48 | | - && let ExprKind::Call(func, [arg]) = expr.kind |
49 | | - && let ExprKind::Path(func_path) = func.kind |
50 | | - && last_path_segment(&func_path).ident.name == sym::new |
| 45 | + if let ExprKind::Call(func, [arg]) = expr.kind |
| 46 | + && let ExprKind::Path(QPath::TypeRelative(func_ty, func_name)) = func.kind |
| 47 | + && func_name.ident.name == sym::new |
| 48 | + && !expr.span.from_expansion() |
| 49 | + && is_type_diagnostic_item(cx, cx.typeck_results().node_type(func_ty.hir_id), sym::Arc) |
51 | 50 | && let arg_ty = cx.typeck_results().expr_ty(arg) |
52 | 51 | // make sure that the type is not and does not contain any type parameters |
53 | 52 | && arg_ty.walk().all(|arg| { |
|
0 commit comments