Skip to content

Commit b6c0e0e

Browse files
authored
Merge pull request #223 from greyblake/fix-clippy-rustc-1.89
Fix clippy
2 parents edc2d3b + ee72b00 commit b6c0e0e

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

nutype_macros/src/common/parse/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ where
129129
} else {
130130
// HACK: we want to propagate the original error in case if it was `regex` attribute.
131131
// Most likely it was not parsed, because `regex` feature was not enabled.
132-
if let Ok(ident) = input.fork().parse::<Ident>() {
133-
if ident == "regex" {
134-
// Parse again and return the original error
135-
input.fork().parse::<Validator>()?;
136-
}
132+
if let Ok(ident) = input.fork().parse::<Ident>()
133+
&& ident == "regex"
134+
{
135+
// Parse again and return the original error
136+
input.fork().parse::<Validator>()?;
137137
}
138138

139139
let possible_values: String = <Validator as Kinded>::Kind::all()

nutype_macros/src/common/validate.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,26 @@ where
127127
}
128128

129129
// less VS greater
130-
if let (Some(lower), Some(upper)) = (maybe_greater.clone(), maybe_less.clone()) {
131-
if lower.item >= upper.item {
132-
let msg = "The lower bound (`greater`) cannot be equal or higher than the upper bound (`less`).";
133-
let err = syn::Error::new(upper.span(), msg);
134-
return Err(err);
135-
}
130+
if let (Some(lower), Some(upper)) = (maybe_greater.clone(), maybe_less.clone())
131+
&& lower.item >= upper.item
132+
{
133+
let msg =
134+
"The lower bound (`greater`) cannot be equal or higher than the upper bound (`less`).";
135+
let err = syn::Error::new(upper.span(), msg);
136+
return Err(err);
136137
}
137138

138139
let maybe_lower_bound = maybe_greater.or(maybe_greater_or_equal);
139140
let maybe_upper_bound = maybe_less.or(maybe_less_or_equal);
140141

141142
// less_or_equal VS greater_or_equal
142143
//
143-
if let (Some(lower), Some(upper)) = (maybe_lower_bound, maybe_upper_bound) {
144-
if lower.item > upper.item {
145-
let msg = "The lower bound (`greater` or `greater_or_equal`) cannot be greater than the upper bound (`less or `less_or_equal`).\nSometimes we all need a little break.";
146-
let err = syn::Error::new(upper.span(), msg);
147-
return Err(err);
148-
}
144+
if let (Some(lower), Some(upper)) = (maybe_lower_bound, maybe_upper_bound)
145+
&& lower.item > upper.item
146+
{
147+
let msg = "The lower bound (`greater` or `greater_or_equal`) cannot be greater than the upper bound (`less or `less_or_equal`).\nSometimes we all need a little break.";
148+
let err = syn::Error::new(upper.span(), msg);
149+
return Err(err);
149150
}
150151

151152
Ok(())

nutype_macros/src/string/validate.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ fn validate_validators(
5454
.next();
5555
if let (Some((_, len_char_min)), Some((len_char_max_span, len_char_max))) =
5656
(maybe_len_char_min, maybe_len_char_max)
57+
&& len_char_min > len_char_max
5758
{
58-
if len_char_min > len_char_max {
59-
let msg = "`len_char_min` cannot be greater than `len_char_max`.\nDon't you find this obvious?";
60-
let err = syn::Error::new(len_char_max_span, msg);
61-
return Err(err);
62-
}
59+
let msg =
60+
"`len_char_min` cannot be greater than `len_char_max`.\nDon't you find this obvious?";
61+
let err = syn::Error::new(len_char_max_span, msg);
62+
return Err(err);
6363
}
6464

6565
// Validate regex

0 commit comments

Comments
 (0)