From 11066fbbddffb09a25ebaedff429d5ff6192d8be Mon Sep 17 00:00:00 2001 From: Akshay Date: Sat, 4 Jun 2022 21:52:57 +0530 Subject: raise, don't fix for empty_let_in with comments --- lib/src/lints/empty_let_in.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/src/lints') diff --git a/lib/src/lints/empty_let_in.rs b/lib/src/lints/empty_let_in.rs index 390a1e1..0714ac0 100644 --- a/lib/src/lints/empty_let_in.rs +++ b/lib/src/lints/empty_let_in.rs @@ -1,5 +1,3 @@ -use std::ops::Not; - use crate::{session::SessionInfo, Metadata, Report, Rule, Suggestion}; use if_chain::if_chain; @@ -49,15 +47,18 @@ impl Rule for EmptyLetIn { if let Some(body) = let_in_expr.body(); // ensure that the let-in-expr does not have comments - if node + let has_comments = node .children_with_tokens() - .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT) - .not(); + .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT); then { let at = node.text_range(); let replacement = body; let message = "This let-in expression has no entries"; - Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) + Some(if has_comments { + self.report().diagnostic(at, message) + } else { + self.report().suggest(at, message, Suggestion::new(at, replacement)) + }) } else { None } -- cgit v1.2.3