diff options
author | Akshay <[email protected]> | 2022-06-04 17:22:57 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2022-06-04 17:24:01 +0100 |
commit | 11066fbbddffb09a25ebaedff429d5ff6192d8be (patch) | |
tree | c354c2e939323d357efb1d2cac792c32b99a6b83 /lib | |
parent | 33490aa211fdd2b2292c396002123035e0b1fe54 (diff) |
raise, don't fix for empty_let_in with comments
Diffstat (limited to 'lib')
-rw-r--r-- | lib/src/lints/empty_let_in.rs | 13 |
1 files changed, 7 insertions, 6 deletions
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 @@ | |||
1 | use std::ops::Not; | ||
2 | |||
3 | use crate::{session::SessionInfo, Metadata, Report, Rule, Suggestion}; | 1 | use crate::{session::SessionInfo, Metadata, Report, Rule, Suggestion}; |
4 | 2 | ||
5 | use if_chain::if_chain; | 3 | use if_chain::if_chain; |
@@ -49,15 +47,18 @@ impl Rule for EmptyLetIn { | |||
49 | if let Some(body) = let_in_expr.body(); | 47 | if let Some(body) = let_in_expr.body(); |
50 | 48 | ||
51 | // ensure that the let-in-expr does not have comments | 49 | // ensure that the let-in-expr does not have comments |
52 | if node | 50 | let has_comments = node |
53 | .children_with_tokens() | 51 | .children_with_tokens() |
54 | .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT) | 52 | .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT); |
55 | .not(); | ||
56 | then { | 53 | then { |
57 | let at = node.text_range(); | 54 | let at = node.text_range(); |
58 | let replacement = body; | 55 | let replacement = body; |
59 | let message = "This let-in expression has no entries"; | 56 | let message = "This let-in expression has no entries"; |
60 | Some(self.report().suggest(at, message, Suggestion::new(at, replacement))) | 57 | Some(if has_comments { |
58 | self.report().diagnostic(at, message) | ||
59 | } else { | ||
60 | self.report().suggest(at, message, Suggestion::new(at, replacement)) | ||
61 | }) | ||
61 | } else { | 62 | } else { |
62 | None | 63 | None |
63 | } | 64 | } |