diff options
author | Akshay <[email protected]> | 2021-11-03 09:18:35 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-11-08 05:03:13 +0000 |
commit | 4e063b2abc402ac4d6902647e821978269025c7d (patch) | |
tree | a8935a5432fe86d0e5facb9ff8acc71edcb7f782 /lib/src/lints/useless_parens.rs | |
parent | 78decf580d22fa792c19c40ace39762fb027067c (diff) |
add snapshot test suitesnapshot-tests
Diffstat (limited to 'lib/src/lints/useless_parens.rs')
-rw-r--r-- | lib/src/lints/useless_parens.rs | 10 |
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}; | |||
3 | use if_chain::if_chain; | 3 | use if_chain::if_chain; |
4 | use macros::lint; | 4 | use macros::lint; |
5 | use rnix::{ | 5 | use 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); |