Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some unnecessary parens in assert! conditions #135945

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions library/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 library/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 library/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 library/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 library/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]);
}
30 changes: 15 additions & 15 deletions src/tools/miri/tests/pass/binops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

fn test_nil() {
assert_eq!((), ());
assert!((!(() != ())));
assert!((!(() < ())));
assert!((() <= ()));
assert!((!(() > ())));
assert!((() >= ()));
assert!(!(() != ()));
assert!(!(() < ()));
assert!(() <= ());
assert!(!(() > ()));
assert!(() >= ());
}

fn test_bool() {
assert!((!(true < false)));
assert!((!(true <= false)));
assert!((true > false));
assert!((true >= false));
assert!(!(true < false));
assert!(!(true <= false));
assert!(true > false);
assert!(true >= false);

assert!((false < true));
assert!((false <= true));
assert!((!(false > true)));
assert!((!(false >= true)));
assert!(false < true);
assert!(false <= true);
assert!(!(false > true));
assert!(!(false >= true));

// Bools support bitwise binops
assert_eq!(false & false, false);
Expand Down Expand Up @@ -65,9 +65,9 @@ fn test_class() {

assert_eq!(q, r);
r.y = 17;
assert!((r.y != q.y));
assert!(r.y != q.y);
assert_eq!(r.y, 17);
assert!((q != r));
assert!(q != r);
}

pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/binding/expr-match-generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type compare<T> = extern "Rust" fn(T, T) -> bool;

fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") };
assert!((eq(expected, actual)));
assert!(eq(expected, actual));
}

fn test_bool() {
Expand Down
13 changes: 5 additions & 8 deletions tests/ui/binding/expr-match.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
//@ run-pass




// Tests for using match as an expression

fn test_basic() {
let mut rs: bool = match true { true => { true } false => { false } };
assert!((rs));
assert!(rs);
rs = match false { true => { false } false => { true } };
assert!((rs));
assert!(rs);
}

fn test_inferrence() {
let rs = match true { true => { true } false => { false } };
assert!((rs));
assert!(rs);
}

fn test_alt_as_alt_head() {
Expand All @@ -25,7 +22,7 @@ fn test_alt_as_alt_head() {
true => { false }
false => { true }
};
assert!((rs));
assert!(rs);
}

fn test_alt_as_block_result() {
Expand All @@ -34,7 +31,7 @@ fn test_alt_as_block_result() {
true => { false }
false => { match true { true => { true } false => { false } } }
};
assert!((rs));
assert!(rs);
}

pub fn main() {
Expand Down
30 changes: 15 additions & 15 deletions tests/ui/binop/binops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@

fn test_nil() {
assert_eq!((), ());
assert!((!(() != ())));
assert!((!(() < ())));
assert!((() <= ()));
assert!((!(() > ())));
assert!((() >= ()));
assert!(!(() != ()));
assert!(!(() < ()));
assert!(() <= ());
assert!(!(() > ()));
assert!(() >= ());
}

fn test_bool() {
assert!((!(true < false)));
assert!((!(true <= false)));
assert!((true > false));
assert!((true >= false));
assert!(!(true < false));
assert!(!(true <= false));
assert!(true > false);
assert!(true >= false);

assert!((false < true));
assert!((false <= true));
assert!((!(false > true)));
assert!((!(false >= true)));
assert!(false < true);
assert!(false <= true);
assert!(!(false > true));
assert!(!(false >= true));

// Bools support bitwise binops
assert_eq!(false & false, false);
Expand Down Expand Up @@ -76,9 +76,9 @@ fn test_class() {
}
assert_eq!(q, r);
r.y = 17;
assert!((r.y != q.y));
assert!(r.y != q.y);
assert_eq!(r.y, 17);
assert!((q != r));
assert!(q != r);
}

pub fn main() {
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/binop/structured-compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ pub fn main() {
let a = (1, 2, 3);
let b = (1, 2, 3);
assert_eq!(a, b);
assert!((a != (1, 2, 4)));
assert!((a < (1, 2, 4)));
assert!((a <= (1, 2, 4)));
assert!(((1, 2, 4) > a));
assert!(((1, 2, 4) >= a));
assert!(a != (1, 2, 4));
assert!(a < (1, 2, 4));
assert!(a <= (1, 2, 4));
assert!((1, 2, 4) > a);
assert!((1, 2, 4) >= a);
let x = foo::large;
let y = foo::small;
assert!((x != y));
assert!(x != y);
assert_eq!(x, foo::large);
assert!((x != foo::small));
assert!(x != foo::small);
}
2 changes: 1 addition & 1 deletion tests/ui/cfg/conditional-compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn main() {
pub fn main() {
// Exercise some of the configured items in ways that wouldn't be possible
// if they had the FALSE definition
assert!((b));
assert!(b);
let _x: t = true;
let _y: tg = tg::bar;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/expr/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Tests for standalone blocks as expressions

fn test_basic() { let rs: bool = { true }; assert!((rs)); }
fn test_basic() { let rs: bool = { true }; assert!(rs); }

struct RS { v1: isize, v2: isize }

Expand Down
18 changes: 9 additions & 9 deletions tests/ui/expr/if/expr-if.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
//@ run-pass
// Tests for if as expressions

fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); }
fn test_if() { let rs: bool = if true { true } else { false }; assert!(rs); }

fn test_else() {
let rs: bool = if false { false } else { true };
assert!((rs));
assert!(rs);
}

fn test_elseif1() {
let rs: bool = if true { true } else if true { false } else { false };
assert!((rs));
assert!(rs);
}

fn test_elseif2() {
let rs: bool = if false { false } else if true { true } else { false };
assert!((rs));
assert!(rs);
}

fn test_elseif3() {
let rs: bool = if false { false } else if false { false } else { true };
assert!((rs));
assert!(rs);
}

fn test_inferrence() {
let rs = if true { true } else { false };
assert!((rs));
assert!(rs);
}

fn test_if_as_if_condition() {
let rs1 = if if false { false } else { true } { true } else { false };
assert!((rs1));
assert!(rs1);
let rs2 = if if true { false } else { true } { false } else { true };
assert!((rs2));
assert!(rs2);
}

fn test_if_as_block_result() {
let rs = if true { if false { false } else { true } } else { false };
assert!((rs));
assert!(rs);
}

pub fn main() {
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/for-loop-while/break.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ pub fn main() {
assert_eq!(i, 20);
let xs = [1, 2, 3, 4, 5, 6];
for x in &xs {
if *x == 3 { break; } assert!((*x <= 3));
if *x == 3 { break; } assert!(*x <= 3);
}
i = 0;
while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); }
while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!(i % 2 != 0); }
i = 0;
loop {
i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0));
i += 1; if i % 2 == 0 { continue; } assert!(i % 2 != 0);
if i >= 10 { break; }
}
let ys = vec![1, 2, 3, 4, 5, 6];
for x in &ys {
if *x % 2 == 0 { continue; }
assert!((*x % 2 != 0));
assert!(*x % 2 != 0);
}
}
2 changes: 1 addition & 1 deletion tests/ui/for-loop-while/while-cont.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pub fn main() {
let mut i = 1;
while i > 0 {
assert!((i > 0));
assert!(i > 0);
println!("{}", i);
i -= 1;
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/for-loop-while/while-loop-constraints-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ pub fn main() {
while false { x = y; y = z; }
println!("{}", y);
}
assert!((y == 42 && z == 50));
assert!(y == 42 && z == 50);
}
Loading
Loading