Skip to content

Commit b6f4e52

Browse files
committed
also accept constructors of tuple structs and enum variants
1 parent 762476e commit b6f4e52

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/needless_path_new.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::path_res;
33
use clippy_utils::source::snippet;
44
use clippy_utils::ty::implements_trait;
55
use rustc_errors::Applicability;
6-
use rustc_hir::def::{DefKind, Res};
6+
use rustc_hir::def::{CtorKind, DefKind, Res};
77
use rustc_hir::def_id::DefId;
88
use rustc_hir::{Expr, ExprKind, QPath};
99
use rustc_lint::{LateContext, LateLintPass};
@@ -68,7 +68,8 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPathNew<'tcx> {
6868

6969
let (fn_did, args) = match e.kind {
7070
ExprKind::Call(callee, args)
71-
if let Res::Def(DefKind::Fn | DefKind::AssocFn, did) = path_res(cx, callee) =>
71+
if let Res::Def(DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn), did) =
72+
path_res(cx, callee) =>
7273
{
7374
(did, args)
7475
},

0 commit comments

Comments
 (0)