Skip to content

Commit 6275e77

Browse files
committed
Do not check twice whether qpath is a QPath::TypeRelative variant
1 parent 646b28f commit 6275e77

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

clippy_lints/src/manual_string_new.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,16 @@ fn parse_call(cx: &LateContext<'_>, span: Span, func: &Expr<'_>, args: &[Expr<'_
108108

109109
let arg_kind = &args[0].kind;
110110
if let ExprKind::Path(qpath) = &func.kind {
111-
if let QPath::TypeRelative(_, _) = qpath {
112-
// String::from(...) or String::try_from(...)
113-
if let QPath::TypeRelative(ty, path_seg) = qpath
114-
&& [sym::from, sym::try_from].contains(&path_seg.ident.name)
115-
&& let TyKind::Path(qpath) = &ty.kind
116-
&& let QPath::Resolved(_, path) = qpath
117-
&& let [path_seg] = path.segments
118-
&& path_seg.ident.name == sym::String
119-
&& is_expr_kind_empty_str(arg_kind)
120-
{
121-
warn_then_suggest(cx, span);
122-
}
111+
// String::from(...) or String::try_from(...)
112+
if let QPath::TypeRelative(ty, path_seg) = qpath
113+
&& [sym::from, sym::try_from].contains(&path_seg.ident.name)
114+
&& let TyKind::Path(qpath) = &ty.kind
115+
&& let QPath::Resolved(_, path) = qpath
116+
&& let [path_seg] = path.segments
117+
&& path_seg.ident.name == sym::String
118+
&& is_expr_kind_empty_str(arg_kind)
119+
{
120+
warn_then_suggest(cx, span);
123121
} else if let QPath::Resolved(_, path) = qpath {
124122
// From::from(...) or TryFrom::try_from(...)
125123
if let [path_seg1, path_seg2] = path.segments

0 commit comments

Comments
 (0)