Skip to content

Commit 623a651

Browse files
fix: remove unnecessary ignored warnings (#134)
1 parent 7a029c7 commit 623a651

6 files changed

Lines changed: 111 additions & 164 deletions

File tree

packages/fortifier/src/validations/email_address.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,13 +460,10 @@ mod tests {
460460
);
461461

462462
assert_eq!((&"admin@localhost").validate_email_address(options), Ok(()));
463-
#[expect(unused_allocation)]
464-
{
465-
assert_eq!(
466-
Box::new("admin@localhost").validate_email_address(options),
467-
Ok(())
468-
);
469-
}
463+
assert_eq!(
464+
Box::new("admin@localhost").validate_email_address(options),
465+
Ok(())
466+
);
470467
assert_eq!(
471468
Arc::new("admin@localhost").validate_email_address(options),
472469
Ok(())
@@ -535,15 +532,12 @@ mod tests {
535532
email_address::Error::MissingSeparator
536533
))
537534
);
538-
#[expect(unused_allocation)]
539-
{
540-
assert_eq!(
541-
Box::new("admin").validate_email_address(options),
542-
Err(EmailAddressError::from(
543-
email_address::Error::MissingSeparator
544-
))
545-
);
546-
}
535+
assert_eq!(
536+
Box::new("admin").validate_email_address(options),
537+
Err(EmailAddressError::from(
538+
email_address::Error::MissingSeparator
539+
))
540+
);
547541
assert_eq!(
548542
Arc::new("admin").validate_email_address(options),
549543
Err(EmailAddressError::from(

packages/fortifier/src/validations/length.rs

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,7 @@ mod tests {
320320
}
321321

322322
assert_eq!((&"a").validate_length(Some(1), None, None), Ok(()));
323-
#[expect(unused_allocation)]
324-
{
325-
assert_eq!(Box::new("a").validate_length(Some(1), None, None), Ok(()));
326-
}
323+
assert_eq!(Box::new("a").validate_length(Some(1), None, None), Ok(()));
327324
assert_eq!(Arc::new("a").validate_length(Some(1), None, None), Ok(()));
328325
assert_eq!(Rc::new("a").validate_length(Some(1), None, None), Ok(()));
329326

@@ -514,19 +511,16 @@ mod tests {
514511
message: "length 1 is not equal to required length 2".to_owned(),
515512
})
516513
);
517-
#[expect(unused_allocation)]
518-
{
519-
assert_eq!(
520-
Box::new("a").validate_length(Some(2), None, None),
521-
Err(LengthError::Equal {
522-
equal: 2,
523-
value: 1,
524-
code: LengthErrorCode,
525-
#[cfg(feature = "message")]
526-
message: "length 1 is not equal to required length 2".to_owned(),
527-
})
528-
);
529-
}
514+
assert_eq!(
515+
Box::new("a").validate_length(Some(2), None, None),
516+
Err(LengthError::Equal {
517+
equal: 2,
518+
value: 1,
519+
code: LengthErrorCode,
520+
#[cfg(feature = "message")]
521+
message: "length 1 is not equal to required length 2".to_owned(),
522+
})
523+
);
530524
assert_eq!(
531525
Arc::new("a").validate_length(Some(2), None, None),
532526
Err(LengthError::Equal {
@@ -750,19 +744,16 @@ mod tests {
750744
message: "length 1 is less than minimum length 3".to_owned(),
751745
})
752746
);
753-
#[expect(unused_allocation)]
754-
{
755-
assert_eq!(
756-
Box::new("a").validate_length(None, Some(3), None),
757-
Err(LengthError::Min {
758-
min: 3,
759-
value: 1,
760-
code: LengthErrorCode,
761-
#[cfg(feature = "message")]
762-
message: "length 1 is less than minimum length 3".to_owned(),
763-
})
764-
);
765-
}
747+
assert_eq!(
748+
Box::new("a").validate_length(None, Some(3), None),
749+
Err(LengthError::Min {
750+
min: 3,
751+
value: 1,
752+
code: LengthErrorCode,
753+
#[cfg(feature = "message")]
754+
message: "length 1 is less than minimum length 3".to_owned(),
755+
})
756+
);
766757
assert_eq!(
767758
Arc::new("a").validate_length(None, Some(3), None),
768759
Err(LengthError::Min {
@@ -986,19 +977,16 @@ mod tests {
986977
message: "length 1 is greater than maximum length 0".to_owned(),
987978
})
988979
);
989-
#[expect(unused_allocation)]
990-
{
991-
assert_eq!(
992-
Box::new("a").validate_length(None, None, Some(0)),
993-
Err(LengthError::Max {
994-
max: 0,
995-
value: 1,
996-
code: LengthErrorCode,
997-
#[cfg(feature = "message")]
998-
message: "length 1 is greater than maximum length 0".to_owned(),
999-
})
1000-
);
1001-
}
980+
assert_eq!(
981+
Box::new("a").validate_length(None, None, Some(0)),
982+
Err(LengthError::Max {
983+
max: 0,
984+
value: 1,
985+
code: LengthErrorCode,
986+
#[cfg(feature = "message")]
987+
message: "length 1 is greater than maximum length 0".to_owned(),
988+
})
989+
);
1002990
assert_eq!(
1003991
Arc::new("a").validate_length(None, None, Some(0)),
1004992
Err(LengthError::Max {

packages/fortifier/src/validations/phone_number.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,10 @@ mod tests {
347347
(&"+44 20 7946 0000").validate_phone_number(None, None),
348348
Ok(())
349349
);
350-
#[expect(unused_allocation)]
351-
{
352-
assert_eq!(
353-
Box::new("+44 20 7946 0000").validate_phone_number(None, None),
354-
Ok(())
355-
);
356-
}
350+
assert_eq!(
351+
Box::new("+44 20 7946 0000").validate_phone_number(None, None),
352+
Ok(())
353+
);
357354
assert_eq!(
358355
Arc::new("+44 20 7946 0000").validate_phone_number(None, None),
359356
Ok(())
@@ -400,13 +397,10 @@ mod tests {
400397
(&"+44").validate_phone_number(None, None),
401398
Err(PhoneNumberError::from(ParseError::NoNumber))
402399
);
403-
#[expect(unused_allocation)]
404-
{
405-
assert_eq!(
406-
Box::new("+44").validate_phone_number(None, None),
407-
Err(PhoneNumberError::from(ParseError::NoNumber))
408-
);
409-
}
400+
assert_eq!(
401+
Box::new("+44").validate_phone_number(None, None),
402+
Err(PhoneNumberError::from(ParseError::NoNumber))
403+
);
410404
assert_eq!(
411405
Arc::new("+44").validate_phone_number(None, None),
412406
Err(PhoneNumberError::from(ParseError::NoNumber))

packages/fortifier/src/validations/range.rs

Lines changed: 44 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,10 @@ mod tests {
414414
{
415415
assert_eq!((&3).validate_range(Some(1), None, None, None), Ok(()));
416416
}
417-
#[expect(unused_allocation)]
418-
{
419-
assert_eq!(
420-
(Box::new(3)).validate_range(Some(1), None, None, None),
421-
Ok(())
422-
);
423-
}
417+
assert_eq!(
418+
(Box::new(3)).validate_range(Some(1), None, None, None),
419+
Ok(())
420+
);
424421
assert_eq!(
425422
(Arc::new(3)).validate_range(Some(1), None, None, None),
426423
Ok(())
@@ -796,19 +793,16 @@ mod tests {
796793
})
797794
);
798795
}
799-
#[expect(unused_allocation)]
800-
{
801-
assert_eq!(
802-
(Box::new(3)).validate_range(Some(4), None, None, None),
803-
Err(RangeError::Min {
804-
min: 4,
805-
value: 3,
806-
code: RangeErrorCode,
807-
#[cfg(feature = "message")]
808-
message: "value 3 is less than minimum value 4".to_owned(),
809-
})
810-
);
811-
}
796+
assert_eq!(
797+
(Box::new(3)).validate_range(Some(4), None, None, None),
798+
Err(RangeError::Min {
799+
min: 4,
800+
value: 3,
801+
code: RangeErrorCode,
802+
#[cfg(feature = "message")]
803+
message: "value 3 is less than minimum value 4".to_owned(),
804+
})
805+
);
812806
assert_eq!(
813807
(Arc::new(3)).validate_range(Some(4), None, None, None),
814808
Err(RangeError::Min {
@@ -1202,19 +1196,16 @@ mod tests {
12021196
})
12031197
);
12041198
}
1205-
#[expect(unused_allocation)]
1206-
{
1207-
assert_eq!(
1208-
(Box::new(3)).validate_range(None, Some(2), None, None),
1209-
Err(RangeError::Max {
1210-
max: 2,
1211-
value: 3,
1212-
code: RangeErrorCode,
1213-
#[cfg(feature = "message")]
1214-
message: "value 3 is greater than maximum value 2".to_owned(),
1215-
})
1216-
);
1217-
}
1199+
assert_eq!(
1200+
(Box::new(3)).validate_range(None, Some(2), None, None),
1201+
Err(RangeError::Max {
1202+
max: 2,
1203+
value: 3,
1204+
code: RangeErrorCode,
1205+
#[cfg(feature = "message")]
1206+
message: "value 3 is greater than maximum value 2".to_owned(),
1207+
})
1208+
);
12181209
assert_eq!(
12191210
(Arc::new(3)).validate_range(None, Some(2), None, None),
12201211
Err(RangeError::Max {
@@ -1615,20 +1606,16 @@ mod tests {
16151606
})
16161607
);
16171608
}
1618-
#[expect(unused_allocation)]
1619-
{
1620-
assert_eq!(
1621-
(Box::new(3)).validate_range(None, None, Some(3), None),
1622-
Err(RangeError::ExclusiveMin {
1623-
exclusive_min: 3,
1624-
value: 3,
1625-
code: RangeErrorCode,
1626-
#[cfg(feature = "message")]
1627-
message: "value 3 is less than or equal to exclusive minimum value 3"
1628-
.to_owned(),
1629-
})
1630-
);
1631-
}
1609+
assert_eq!(
1610+
(Box::new(3)).validate_range(None, None, Some(3), None),
1611+
Err(RangeError::ExclusiveMin {
1612+
exclusive_min: 3,
1613+
value: 3,
1614+
code: RangeErrorCode,
1615+
#[cfg(feature = "message")]
1616+
message: "value 3 is less than or equal to exclusive minimum value 3".to_owned(),
1617+
})
1618+
);
16321619
assert_eq!(
16331620
(Arc::new(3)).validate_range(None, None, Some(3), None),
16341621
Err(RangeError::ExclusiveMin {
@@ -2031,20 +2018,16 @@ mod tests {
20312018
})
20322019
);
20332020
}
2034-
#[expect(unused_allocation)]
2035-
{
2036-
assert_eq!(
2037-
(Box::new(3)).validate_range(None, None, None, Some(3)),
2038-
Err(RangeError::ExclusiveMax {
2039-
exclusive_max: 3,
2040-
value: 3,
2041-
code: RangeErrorCode,
2042-
#[cfg(feature = "message")]
2043-
message: "value 3 is greater than or equal to exclusive maximum value 3"
2044-
.to_owned(),
2045-
})
2046-
);
2047-
}
2021+
assert_eq!(
2022+
(Box::new(3)).validate_range(None, None, None, Some(3)),
2023+
Err(RangeError::ExclusiveMax {
2024+
exclusive_max: 3,
2025+
value: 3,
2026+
code: RangeErrorCode,
2027+
#[cfg(feature = "message")]
2028+
message: "value 3 is greater than or equal to exclusive maximum value 3".to_owned(),
2029+
})
2030+
);
20482031
assert_eq!(
20492032
(Arc::new(3)).validate_range(None, None, None, Some(3)),
20502033
Err(RangeError::ExclusiveMax {

packages/fortifier/src/validations/regex.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,7 @@ mod tests {
188188
assert_eq!(Some("1234").validate_regex(&REGEX), Ok(()));
189189

190190
assert_eq!((&"1234").validate_regex(&REGEX), Ok(()));
191-
#[expect(unused_allocation)]
192-
{
193-
assert_eq!(Box::new("1234").validate_regex(&REGEX), Ok(()));
194-
}
191+
assert_eq!(Box::new("1234").validate_regex(&REGEX), Ok(()));
195192
assert_eq!(Arc::new("1234").validate_regex(&REGEX), Ok(()));
196193
assert_eq!(Rc::new("1234").validate_regex(&REGEX), Ok(()));
197194

@@ -223,17 +220,14 @@ mod tests {
223220
);
224221

225222
assert_eq!((&"123").validate_regex(&REGEX), Err(RegexError::default()));
226-
#[expect(unused_allocation)]
227-
{
228-
assert_eq!(
229-
Box::new("123").validate_regex(&REGEX),
230-
Err(RegexError {
231-
code: RegexErrorCode,
232-
#[cfg(feature = "message")]
233-
message: "value does not match regular expression".to_owned(),
234-
})
235-
);
236-
}
223+
assert_eq!(
224+
Box::new("123").validate_regex(&REGEX),
225+
Err(RegexError {
226+
code: RegexErrorCode,
227+
#[cfg(feature = "message")]
228+
message: "value does not match regular expression".to_owned(),
229+
})
230+
);
237231
assert_eq!(
238232
Arc::new("123").validate_regex(&REGEX),
239233
Err(RegexError::default())

packages/fortifier/src/validations/url.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,7 @@ mod tests {
353353
assert_eq!(Some("http://localhost").validate_url(), Ok(()));
354354

355355
assert_eq!((&"http://localhost").validate_url(), Ok(()));
356-
#[expect(unused_allocation)]
357-
{
358-
assert_eq!(Box::new("http://localhost").validate_url(), Ok(()));
359-
}
356+
assert_eq!(Box::new("http://localhost").validate_url(), Ok(()));
360357
assert_eq!(Arc::new("http://localhost").validate_url(), Ok(()));
361358
assert_eq!(Rc::new("http://localhost").validate_url(), Ok(()));
362359

@@ -397,17 +394,14 @@ mod tests {
397394
(&"http://").validate_url(),
398395
Err(UrlError::from(ParseError::EmptyHost))
399396
);
400-
#[expect(unused_allocation)]
401-
{
402-
assert_eq!(
403-
Box::new("http://").validate_url(),
404-
Err(UrlError::EmptyHost {
405-
code: UrlErrorCode,
406-
#[cfg(feature = "message")]
407-
message: "empty host".to_owned(),
408-
})
409-
);
410-
}
397+
assert_eq!(
398+
Box::new("http://").validate_url(),
399+
Err(UrlError::EmptyHost {
400+
code: UrlErrorCode,
401+
#[cfg(feature = "message")]
402+
message: "empty host".to_owned(),
403+
})
404+
);
411405
assert_eq!(
412406
Arc::new("http://").validate_url(),
413407
Err(UrlError::from(ParseError::EmptyHost))

0 commit comments

Comments
 (0)