From 33490aa211fdd2b2292c396002123035e0b1fe54 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 4 Jun 2022 16:20:19 +0530 Subject: do not raise empty-let when comments are present --- lib/src/lints/empty_let_in.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/src') diff --git a/lib/src/lints/empty_let_in.rs b/lib/src/lints/empty_let_in.rs index e42f658..390a1e1 100644 --- a/lib/src/lints/empty_let_in.rs +++ b/lib/src/lints/empty_let_in.rs @@ -1,3 +1,5 @@ +use std::ops::Not; + use crate::{session::SessionInfo, Metadata, Report, Rule, Suggestion}; use if_chain::if_chain; @@ -45,6 +47,12 @@ impl Rule for EmptyLetIn { if inherits.count() == 0; if let Some(body) = let_in_expr.body(); + + // ensure that the let-in-expr does not have comments + if node + .children_with_tokens() + .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT) + .not(); then { let at = node.text_range(); let replacement = body; -- cgit v1.2.3