Skip to content

Commit

Permalink
Remove some unnecessary parens in assert! conditions
Browse files Browse the repository at this point in the history
While working on rust-lang#122661, some of these started triggering our "unnecessary parens" lints due to a change in the `assert!` desugaring. A cursory search identified a few more. Some of these have been carried from before 1.0, were a bulk rename from the previous name of `assert!` left them in that state. I went and removed as many of these unnecessary parens as possible in order to have fewer annoyances in the future if we make the lint smarter.
  • Loading branch information
estebank authored and gitbot committed Feb 20, 2025
1 parent f5cf4cc commit 7960886
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
22 changes: 11 additions & 11 deletions alloc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2297,21 +2297,21 @@ fn utf8_chars() {
assert_eq!(schs.len(), 4);
assert_eq!(schs.iter().cloned().collect::<String>(), s);

assert!((from_utf8(s.as_bytes()).is_ok()));
assert!(from_utf8(s.as_bytes()).is_ok());
// invalid prefix
assert!((!from_utf8(&[0x80]).is_ok()));
assert!(!from_utf8(&[0x80]).is_ok());
// invalid 2 byte prefix
assert!((!from_utf8(&[0xc0]).is_ok()));
assert!((!from_utf8(&[0xc0, 0x10]).is_ok()));
assert!(!from_utf8(&[0xc0]).is_ok());
assert!(!from_utf8(&[0xc0, 0x10]).is_ok());
// invalid 3 byte prefix
assert!((!from_utf8(&[0xe0]).is_ok()));
assert!((!from_utf8(&[0xe0, 0x10]).is_ok()));
assert!((!from_utf8(&[0xe0, 0xff, 0x10]).is_ok()));
assert!(!from_utf8(&[0xe0]).is_ok());
assert!(!from_utf8(&[0xe0, 0x10]).is_ok());
assert!(!from_utf8(&[0xe0, 0xff, 0x10]).is_ok());
// invalid 4 byte prefix
assert!((!from_utf8(&[0xf0]).is_ok()));
assert!((!from_utf8(&[0xf0, 0x10]).is_ok()));
assert!((!from_utf8(&[0xf0, 0xff, 0x10]).is_ok()));
assert!((!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok()));
assert!(!from_utf8(&[0xf0]).is_ok());
assert!(!from_utf8(&[0xf0, 0x10]).is_ok());
assert!(!from_utf8(&[0xf0, 0xff, 0x10]).is_ok());
assert!(!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok());
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions coretests/tests/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ fn test_bool() {
#[test]
pub fn test_bool_not() {
if !false {
assert!((true));
assert!(true);
} else {
assert!((false));
assert!(false);
}
if !true {
assert!((false));
assert!(false);
} else {
assert!((true));
assert!(true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions coretests/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ fn test() {
let mut v1 = vec![0u16, 0u16, 0u16];

copy(v0.as_ptr().offset(1), v1.as_mut_ptr().offset(1), 1);
assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
assert!(v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16);
copy(v0.as_ptr().offset(2), v1.as_mut_ptr(), 1);
assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16));
assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16);
copy(v0.as_ptr(), v1.as_mut_ptr().offset(2), 1);
assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16));
assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16);
}
}

Expand Down
4 changes: 2 additions & 2 deletions std/tests/istr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn test_stack_assign() {
let t: String = "a".to_string();
assert_eq!(s, t);
let u: String = "b".to_string();
assert!((s != u));
assert!(s != u);
}

#[test]
Expand All @@ -19,7 +19,7 @@ fn test_heap_assign() {
let t: String = "a big ol' string".to_string();
assert_eq!(s, t);
let u: String = "a bad ol' string".to_string();
assert!((s != u));
assert!(s != u);
}

#[test]
Expand Down
22 changes: 11 additions & 11 deletions std/tests/seq-compare.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#[test]
fn seq_compare() {
assert!(("hello".to_string() < "hellr".to_string()));
assert!(("hello ".to_string() > "hello".to_string()));
assert!(("hello".to_string() != "there".to_string()));
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
assert!((vec![1, 2, 3] < vec![1, 2, 3, 4]));
assert!((vec![1, 2, 4, 4] > vec![1, 2, 3, 4]));
assert!((vec![1, 2, 3, 4] < vec![1, 2, 4, 4]));
assert!((vec![1, 2, 3] <= vec![1, 2, 3]));
assert!((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
assert!("hello".to_string() < "hellr".to_string());
assert!("hello ".to_string() > "hello".to_string());
assert!("hello".to_string() != "there".to_string());
assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]);
assert!(vec![1, 2, 3] < vec![1, 2, 3, 4]);
assert!(vec![1, 2, 4, 4] > vec![1, 2, 3, 4]);
assert!(vec![1, 2, 3, 4] < vec![1, 2, 4, 4]);
assert!(vec![1, 2, 3] <= vec![1, 2, 3]);
assert!(vec![1, 2, 3] <= vec![1, 2, 3, 3]);
assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]);
assert_eq!(vec![1, 2, 3], vec![1, 2, 3]);
assert!((vec![1, 2, 3] != vec![1, 1, 3]));
assert!(vec![1, 2, 3] != vec![1, 1, 3]);
}

0 comments on commit 7960886

Please sign in to comment.