···66 )
77 (
88 let
99- # don't match this, we have a comment
99+ # don't fix this, we have a comment
1010+ # raise the lint though
1011 in
1112 null
1213 )
+8
bin/tests/snapshots/main__empty_let_in.snap
···1111 · │
1212 · ╰────────────── This let-in expression has no entries
1313───╯
1414+[W02] Warning: Useless let-in expression
1515+ ╭─[data/empty_let_in.nix:8:5]
1616+ │
1717+ 8 │ ╭─▶ let
1818+ 12 │ ├─▶ null
1919+ · │
2020+ · ╰────────────── This let-in expression has no entries
2121+────╯
1422
+7-6
lib/src/lints/empty_let_in.rs
···11-use std::ops::Not;
22-31use crate::{session::SessionInfo, Metadata, Report, Rule, Suggestion};
4253use if_chain::if_chain;
···4947 if let Some(body) = let_in_expr.body();
50485149 // ensure that the let-in-expr does not have comments
5252- if node
5050+ let has_comments = node
5351 .children_with_tokens()
5454- .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT)
5555- .not();
5252+ .any(|el| el.kind() == SyntaxKind::TOKEN_COMMENT);
5653 then {
5754 let at = node.text_range();
5855 let replacement = body;
5956 let message = "This let-in expression has no entries";
6060- Some(self.report().suggest(at, message, Suggestion::new(at, replacement)))
5757+ Some(if has_comments {
5858+ self.report().diagnostic(at, message)
5959+ } else {
6060+ self.report().suggest(at, message, Suggestion::new(at, replacement))
6161+ })
6162 } else {
6263 None
6364 }