Skip to content

Commit 0dc5c94

Browse files
estebankgitbot
authored and
gitbot
committed
Remove some unnecessary parens in assert! conditions
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.
1 parent 902bacd commit 0dc5c94

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

alloc/tests/str.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -2297,21 +2297,21 @@ fn utf8_chars() {
22972297
assert_eq!(schs.len(), 4);
22982298
assert_eq!(schs.iter().cloned().collect::<String>(), s);
22992299

2300-
assert!((from_utf8(s.as_bytes()).is_ok()));
2300+
assert!(from_utf8(s.as_bytes()).is_ok());
23012301
// invalid prefix
2302-
assert!((!from_utf8(&[0x80]).is_ok()));
2302+
assert!(!from_utf8(&[0x80]).is_ok());
23032303
// invalid 2 byte prefix
2304-
assert!((!from_utf8(&[0xc0]).is_ok()));
2305-
assert!((!from_utf8(&[0xc0, 0x10]).is_ok()));
2304+
assert!(!from_utf8(&[0xc0]).is_ok());
2305+
assert!(!from_utf8(&[0xc0, 0x10]).is_ok());
23062306
// invalid 3 byte prefix
2307-
assert!((!from_utf8(&[0xe0]).is_ok()));
2308-
assert!((!from_utf8(&[0xe0, 0x10]).is_ok()));
2309-
assert!((!from_utf8(&[0xe0, 0xff, 0x10]).is_ok()));
2307+
assert!(!from_utf8(&[0xe0]).is_ok());
2308+
assert!(!from_utf8(&[0xe0, 0x10]).is_ok());
2309+
assert!(!from_utf8(&[0xe0, 0xff, 0x10]).is_ok());
23102310
// invalid 4 byte prefix
2311-
assert!((!from_utf8(&[0xf0]).is_ok()));
2312-
assert!((!from_utf8(&[0xf0, 0x10]).is_ok()));
2313-
assert!((!from_utf8(&[0xf0, 0xff, 0x10]).is_ok()));
2314-
assert!((!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok()));
2311+
assert!(!from_utf8(&[0xf0]).is_ok());
2312+
assert!(!from_utf8(&[0xf0, 0x10]).is_ok());
2313+
assert!(!from_utf8(&[0xf0, 0xff, 0x10]).is_ok());
2314+
assert!(!from_utf8(&[0xf0, 0xff, 0xff, 0x10]).is_ok());
23152315
}
23162316

23172317
#[test]

coretests/tests/bool.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ fn test_bool() {
7171
#[test]
7272
pub fn test_bool_not() {
7373
if !false {
74-
assert!((true));
74+
assert!(true);
7575
} else {
76-
assert!((false));
76+
assert!(false);
7777
}
7878
if !true {
79-
assert!((false));
79+
assert!(false);
8080
} else {
81-
assert!((true));
81+
assert!(true);
8282
}
8383
}
8484

coretests/tests/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ fn test() {
4242
let mut v1 = vec![0u16, 0u16, 0u16];
4343

4444
copy(v0.as_ptr().offset(1), v1.as_mut_ptr().offset(1), 1);
45-
assert!((v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16));
45+
assert!(v1[0] == 0u16 && v1[1] == 32001u16 && v1[2] == 0u16);
4646
copy(v0.as_ptr().offset(2), v1.as_mut_ptr(), 1);
47-
assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16));
47+
assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 0u16);
4848
copy(v0.as_ptr(), v1.as_mut_ptr().offset(2), 1);
49-
assert!((v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16));
49+
assert!(v1[0] == 32002u16 && v1[1] == 32001u16 && v1[2] == 32000u16);
5050
}
5151
}
5252

std/tests/istr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fn test_stack_assign() {
55
let t: String = "a".to_string();
66
assert_eq!(s, t);
77
let u: String = "b".to_string();
8-
assert!((s != u));
8+
assert!(s != u);
99
}
1010

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

2525
#[test]

std/tests/seq-compare.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#[test]
22
fn seq_compare() {
3-
assert!(("hello".to_string() < "hellr".to_string()));
4-
assert!(("hello ".to_string() > "hello".to_string()));
5-
assert!(("hello".to_string() != "there".to_string()));
6-
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
7-
assert!((vec![1, 2, 3] < vec![1, 2, 3, 4]));
8-
assert!((vec![1, 2, 4, 4] > vec![1, 2, 3, 4]));
9-
assert!((vec![1, 2, 3, 4] < vec![1, 2, 4, 4]));
10-
assert!((vec![1, 2, 3] <= vec![1, 2, 3]));
11-
assert!((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
12-
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
3+
assert!("hello".to_string() < "hellr".to_string());
4+
assert!("hello ".to_string() > "hello".to_string());
5+
assert!("hello".to_string() != "there".to_string());
6+
assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]);
7+
assert!(vec![1, 2, 3] < vec![1, 2, 3, 4]);
8+
assert!(vec![1, 2, 4, 4] > vec![1, 2, 3, 4]);
9+
assert!(vec![1, 2, 3, 4] < vec![1, 2, 4, 4]);
10+
assert!(vec![1, 2, 3] <= vec![1, 2, 3]);
11+
assert!(vec![1, 2, 3] <= vec![1, 2, 3, 3]);
12+
assert!(vec![1, 2, 3, 4] > vec![1, 2, 3]);
1313
assert_eq!(vec![1, 2, 3], vec![1, 2, 3]);
14-
assert!((vec![1, 2, 3] != vec![1, 1, 3]));
14+
assert!(vec![1, 2, 3] != vec![1, 1, 3]);
1515
}

0 commit comments

Comments
 (0)