Skip to content

Commit f46c981

Browse files
committed
manual_main_separator_str: Check HIR tree first.
1 parent 2d9e67e commit f46c981

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/manual_main_separator_str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ impl_lint_pass!(ManualMainSeparatorStr => [MANUAL_MAIN_SEPARATOR_STR]);
4747

4848
impl LateLintPass<'_> for ManualMainSeparatorStr {
4949
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
50-
if self.msrv.meets(msrvs::PATH_MAIN_SEPARATOR_STR)
51-
&& let (target, _) = peel_hir_expr_refs(expr)
52-
&& is_trait_method(cx, target, sym::ToString)
53-
&& let ExprKind::MethodCall(path, receiver, &[], _) = target.kind
50+
let (target, _) = peel_hir_expr_refs(expr);
51+
if let ExprKind::MethodCall(path, receiver, &[], _) = target.kind
5452
&& path.ident.name == sym::to_string
5553
&& let ExprKind::Path(QPath::Resolved(None, path)) = receiver.kind
5654
&& let Res::Def(DefKind::Const, receiver_def_id) = path.res
55+
&& is_trait_method(cx, target, sym::ToString)
56+
&& self.msrv.meets(msrvs::PATH_MAIN_SEPARATOR_STR)
5757
&& match_def_path(cx, receiver_def_id, &paths::PATH_MAIN_SEPARATOR)
5858
&& let ty::Ref(_, ty, Mutability::Not) = cx.typeck_results().expr_ty_adjusted(expr).kind()
5959
&& ty.is_str()

0 commit comments

Comments
 (0)