aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lints/useless_parens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/lints/useless_parens.rs')
-rw-r--r--lib/src/lints/useless_parens.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/src/lints/useless_parens.rs b/lib/src/lints/useless_parens.rs
index 45d80ae..dccc717 100644
--- a/lib/src/lints/useless_parens.rs
+++ b/lib/src/lints/useless_parens.rs
@@ -3,7 +3,7 @@ use crate::{Diagnostic, Metadata, Report, Rule, Suggestion};
3use if_chain::if_chain; 3use if_chain::if_chain;
4use macros::lint; 4use macros::lint;
5use rnix::{ 5use rnix::{
6 types::{KeyValue, Paren, ParsedType, TypedNode, Wrapper}, 6 types::{KeyValue, LetIn, Paren, ParsedType, TypedNode, Wrapper},
7 NodeOrToken, SyntaxElement, SyntaxKind, 7 NodeOrToken, SyntaxElement, SyntaxKind,
8}; 8};
9 9
@@ -71,7 +71,7 @@ fn do_thing(parsed_type_node: ParsedType) -> Option<Diagnostic> {
71 if let Some(inner) = value_in_parens.inner(); 71 if let Some(inner) = value_in_parens.inner();
72 then { 72 then {
73 let at = value_range; 73 let at = value_range;
74 let message = "Useless parentheses around value in `let` binding"; 74 let message = "Useless parentheses around value in binding";
75 let replacement = inner; 75 let replacement = inner;
76 Some(Diagnostic::suggest(at, message, Suggestion::new(at, replacement))) 76 Some(Diagnostic::suggest(at, message, Suggestion::new(at, replacement)))
77 } else { 77 } else {
@@ -98,7 +98,11 @@ fn do_thing(parsed_type_node: ParsedType) -> Option<Diagnostic> {
98 98
99 // ensure that we don't lint inside let-in statements 99 // ensure that we don't lint inside let-in statements
100 // we already lint such cases in previous match stmt 100 // we already lint such cases in previous match stmt
101 if KeyValue::cast(father_node).is_none(); 101 if KeyValue::cast(father_node.clone()).is_none();
102
103 // ensure that we don't lint inside let-bodies
104 // if this primitive is a let-body, we have already linted it
105 if LetIn::cast(father_node).is_none();
102 106
103 if let Some(inner_node) = paren_expr.inner(); 107 if let Some(inner_node) = paren_expr.inner();
104 if let Some(parsed_inner) = ParsedType::cast(inner_node); 108 if let Some(parsed_inner) = ParsedType::cast(inner_node);