@@ -21,67 +21,58 @@ pub fn validate_node_fn(parsed: &ParsedNodeFn) -> syn::Result<()> {
21
21
22
22
fn validate_min_max ( parsed : & ParsedNodeFn ) {
23
23
for field in & parsed. fields {
24
- match field {
25
- ParsedField :: Regular {
26
- number_hard_max,
27
- number_hard_min,
28
- number_soft_max,
29
- number_soft_min,
30
- pat_ident,
31
- ..
32
- } => {
33
- match ( number_soft_min, number_hard_min) {
34
- ( Some ( soft_min) , Some ( hard_min) ) => {
35
- let soft_min_value: f64 = soft_min. base10_parse ( ) . unwrap_or_default ( ) ;
36
- let hard_min_value: f64 = hard_min. base10_parse ( ) . unwrap_or_default ( ) ;
37
- if soft_min_value == hard_min_value {
38
- emit_error ! (
39
- pat_ident. span( ) ,
40
- "Unnecessary #[soft_min] attribute on `{}` as #[hard_min] equals to it." ,
41
- pat_ident. ident;
42
- help = "You can safely remove the #[soft_min] attribute from this field." ;
43
- note = "The #[hard_min] also limits the range to same without #[soft_min]" ,
44
- ) ;
45
- } else if soft_min_value < hard_min_value {
46
- emit_error ! (
47
- pat_ident. span( ) ,
48
- "The #[soft_min] attribute exists on `{}` and is lower than #[hard_min]." ,
49
- pat_ident. ident;
50
- help = "You probably meant to reverse the two macros" ;
51
- note = "Allowing the possible range in slider to be more than #[hard_min] doesn't make sense" ,
52
- ) ;
53
- }
54
- }
55
- _ => ( ) ,
24
+ if let ParsedField :: Regular {
25
+ number_hard_max,
26
+ number_hard_min,
27
+ number_soft_max,
28
+ number_soft_min,
29
+ pat_ident,
30
+ ..
31
+ } = field
32
+ {
33
+ if let ( Some ( soft_min) , Some ( hard_min) ) = ( number_soft_min, number_hard_min) {
34
+ let soft_min_value: f64 = soft_min. base10_parse ( ) . unwrap_or_default ( ) ;
35
+ let hard_min_value: f64 = hard_min. base10_parse ( ) . unwrap_or_default ( ) ;
36
+ if soft_min_value == hard_min_value {
37
+ emit_error ! (
38
+ pat_ident. span( ) ,
39
+ "Unnecessary #[soft_min] attribute on `{}`, as #[hard_min] has the same value." ,
40
+ pat_ident. ident;
41
+ help = "You can safely remove the #[soft_min] attribute from this field." ;
42
+ note = "#[soft_min] is redundant when it equals #[hard_min]." ,
43
+ ) ;
44
+ } else if soft_min_value < hard_min_value {
45
+ emit_error ! (
46
+ pat_ident. span( ) ,
47
+ "The #[soft_min] attribute on `{}` is incorrectly greater than #[hard_min]." ,
48
+ pat_ident. ident;
49
+ help = "You probably meant to reverse the two attribute values." ;
50
+ note = "Allowing the possible slider range to preceed #[hard_min] doesn't make sense." ,
51
+ ) ;
56
52
}
53
+ }
57
54
58
- match ( number_soft_max, number_hard_max) {
59
- ( Some ( soft_max) , Some ( hard_max) ) => {
60
- let soft_max_value: f64 = soft_max. base10_parse ( ) . unwrap_or_default ( ) ;
61
- let hard_max_value: f64 = hard_max. base10_parse ( ) . unwrap_or_default ( ) ;
62
- if soft_max_value == hard_max_value {
63
- emit_error ! (
64
- pat_ident. span( ) ,
65
- "Unnecessary #[soft_max] attribute on `{}` as #[hard_max] equals to it." ,
66
- pat_ident. ident;
67
- help = "You can safely remove the #[soft_max] attribute from this field." ;
68
- note = "The #[hard_max] also limits the range to same without #[soft_max]" ,
69
- ) ;
70
- } else if soft_max_value < hard_max_value {
71
- emit_error ! (
72
- pat_ident. span( ) ,
73
- "The #[soft_max] attribute exists on `{}` and is greater than #[hard_max]." ,
74
- pat_ident. ident;
75
- help = "You probably meant to reverse the two macros" ;
76
- note = "Allowing the possible range in slider to be more than #[hard_max] doesn't make sense" ,
77
- ) ;
78
- }
79
- }
80
- _ => ( ) ,
55
+ if let ( Some ( soft_max) , Some ( hard_max) ) = ( number_soft_max, number_hard_max) {
56
+ let soft_max_value: f64 = soft_max. base10_parse ( ) . unwrap_or_default ( ) ;
57
+ let hard_max_value: f64 = hard_max. base10_parse ( ) . unwrap_or_default ( ) ;
58
+ if soft_max_value == hard_max_value {
59
+ emit_error ! (
60
+ pat_ident. span( ) ,
61
+ "Unnecessary #[soft_max] attribute on `{}`, as #[hard_max] has the same value." ,
62
+ pat_ident. ident;
63
+ help = "You can safely remove the #[soft_max] attribute from this field." ;
64
+ note = "#[soft_max] is redundant when it equals #[hard_max]." ,
65
+ ) ;
66
+ } else if soft_max_value < hard_max_value {
67
+ emit_error ! (
68
+ pat_ident. span( ) ,
69
+ "The #[soft_max] attribute on `{}` is incorrectly greater than #[hard_max]." ,
70
+ pat_ident. ident;
71
+ help = "You probably meant to reverse the two attribute values." ;
72
+ note = "Allowing the possible slider range to exceed #[hard_max] doesn't make sense." ,
73
+ ) ;
81
74
}
82
75
}
83
-
84
- _ => ( ) ,
85
76
}
86
77
}
87
78
}
0 commit comments