Skip to content

Commit 43cffe9

Browse files
committed
auto merge of #11663 : huonw/rust/paren-lint, r=cmr
The parens in `if (true) {}` are not necessary, so we'll warn about them. cc #3070 and #11432
2 parents 40df5a2 + 39713b8 commit 43cffe9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+143
-99
lines changed

src/compiletest/compiletest.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,9 @@ pub fn parse_config(args: ~[~str]) -> config {
140140
adb_test_dir:
141141
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
142142
adb_device_status:
143-
if (opt_str2(matches.opt_str("target")) ==
144-
~"arm-linux-androideabi") {
145-
if (opt_str2(matches.opt_str("adb-test-dir")) !=
146-
~"(none)" &&
147-
opt_str2(matches.opt_str("adb-test-dir")) !=
148-
~"") { true }
149-
else { false }
150-
} else { false },
143+
"arm-linux-androideabi" == opt_str2(matches.opt_str("target")) &&
144+
"(none)" != opt_str2(matches.opt_str("adb-test-dir")) &&
145+
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
151146
test_shard: test::opt_shard(matches.opt_str("test-shard")),
152147
verbose: matches.opt_present("verbose")
153148
}

src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
532532
if !found_flags[i] {
533533
debug!("prefix={} ee.kind={} ee.msg={} line={}",
534534
prefixes[i], ee.kind, ee.msg, line);
535-
if (prefix_matches(line, prefixes[i]) &&
535+
if prefix_matches(line, prefixes[i]) &&
536536
line.contains(ee.kind) &&
537-
line.contains(ee.msg)) {
537+
line.contains(ee.msg) {
538538
found_flags[i] = true;
539539
was_expected = true;
540540
break;

src/libextra/ebml.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,15 +1025,15 @@ mod bench {
10251025
pub fn vuint_at_A_aligned(bh: &mut BenchHarness) {
10261026
use std::vec;
10271027
let data = vec::from_fn(4*100, |i| {
1028-
match (i % 2) {
1028+
match i % 2 {
10291029
0 => 0x80u8,
10301030
_ => i as u8,
10311031
}
10321032
});
10331033
let mut sum = 0u;
10341034
bh.iter(|| {
10351035
let mut i = 0;
1036-
while (i < data.len()) {
1036+
while i < data.len() {
10371037
sum += reader::vuint_at(data, i).val;
10381038
i += 4;
10391039
}
@@ -1044,15 +1044,15 @@ mod bench {
10441044
pub fn vuint_at_A_unaligned(bh: &mut BenchHarness) {
10451045
use std::vec;
10461046
let data = vec::from_fn(4*100+1, |i| {
1047-
match (i % 2) {
1047+
match i % 2 {
10481048
1 => 0x80u8,
10491049
_ => i as u8
10501050
}
10511051
});
10521052
let mut sum = 0u;
10531053
bh.iter(|| {
10541054
let mut i = 1;
1055-
while (i < data.len()) {
1055+
while i < data.len() {
10561056
sum += reader::vuint_at(data, i).val;
10571057
i += 4;
10581058
}
@@ -1063,7 +1063,7 @@ mod bench {
10631063
pub fn vuint_at_D_aligned(bh: &mut BenchHarness) {
10641064
use std::vec;
10651065
let data = vec::from_fn(4*100, |i| {
1066-
match (i % 4) {
1066+
match i % 4 {
10671067
0 => 0x10u8,
10681068
3 => i as u8,
10691069
_ => 0u8
@@ -1072,7 +1072,7 @@ mod bench {
10721072
let mut sum = 0u;
10731073
bh.iter(|| {
10741074
let mut i = 0;
1075-
while (i < data.len()) {
1075+
while i < data.len() {
10761076
sum += reader::vuint_at(data, i).val;
10771077
i += 4;
10781078
}
@@ -1083,7 +1083,7 @@ mod bench {
10831083
pub fn vuint_at_D_unaligned(bh: &mut BenchHarness) {
10841084
use std::vec;
10851085
let data = vec::from_fn(4*100+1, |i| {
1086-
match (i % 4) {
1086+
match i % 4 {
10871087
1 => 0x10u8,
10881088
0 => i as u8,
10891089
_ => 0u8
@@ -1092,7 +1092,7 @@ mod bench {
10921092
let mut sum = 0u;
10931093
bh.iter(|| {
10941094
let mut i = 1;
1095-
while (i < data.len()) {
1095+
while i < data.len() {
10961096
sum += reader::vuint_at(data, i).val;
10971097
i += 4;
10981098
}

src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<E:CLike> Items<E> {
114114

115115
impl<E:CLike> Iterator<E> for Items<E> {
116116
fn next(&mut self) -> Option<E> {
117-
if (self.bits == 0) {
117+
if self.bits == 0 {
118118
return None;
119119
}
120120

src/libextra/getopts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl Matches {
195195

196196
fn opt_val(&self, nm: &str) -> Option<Optval> {
197197
let vals = self.opt_vals(nm);
198-
if (vals.is_empty()) {
198+
if vals.is_empty() {
199199
None
200200
} else {
201201
Some(vals[0].clone())
@@ -797,7 +797,7 @@ pub mod groups {
797797
let slice: || = || { cont = it(ss.slice(slice_start, last_end)) };
798798

799799
// if the limit is larger than the string, lower it to save cycles
800-
if (lim >= fake_i) {
800+
if lim >= fake_i {
801801
lim = fake_i;
802802
}
803803

src/libextra/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ impl<T : Iterator<char>> Parser<T> {
929929
return self.error(~"EOF while parsing string");
930930
}
931931

932-
if (escape) {
932+
if escape {
933933
match self.ch {
934934
'"' => res.push_char('"'),
935935
'\\' => res.push_char('\\'),
@@ -1360,7 +1360,7 @@ impl serialize::Decoder for Decoder {
13601360
/// Test if two json values are less than one another
13611361
impl Ord for Json {
13621362
fn lt(&self, other: &Json) -> bool {
1363-
match (*self) {
1363+
match *self {
13641364
Number(f0) => {
13651365
match *other {
13661366
Number(f1) => f0 < f1,

src/libextra/num/bigint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ impl ToPrimitive for BigUint {
561561
impl FromPrimitive for BigUint {
562562
#[inline]
563563
fn from_i64(n: i64) -> Option<BigUint> {
564-
if (n > 0) {
564+
if n > 0 {
565565
FromPrimitive::from_u64(n as u64)
566-
} else if (n == 0) {
566+
} else if n == 0 {
567567
Some(Zero::zero())
568568
} else {
569569
None

src/libextra/terminfo/parser/compiled.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub fn parse(file: &mut io::Reader,
178178

179179
// Check magic number
180180
let magic = file.read_le_u16();
181-
if (magic != 0x011A) {
181+
if magic != 0x011A {
182182
return Err(format!("invalid magic number: expected {:x} but found {:x}",
183183
0x011A, magic as uint));
184184
}

src/libextra/time.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ pub fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
808808
/// Formats the time according to the format string.
809809
pub fn strftime(format: &str, tm: &Tm) -> ~str {
810810
fn days_in_year(year: int) -> i32 {
811-
if ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0))) {
811+
if (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) {
812812
366 /* Days in a leap year */
813813
} else {
814814
365 /* Days in a non-leap year */
@@ -838,14 +838,14 @@ pub fn strftime(format: &str, tm: &Tm) -> ~str {
838838
let mut year: int = tm.tm_year as int + 1900;
839839
let mut days: int = iso_week_days (tm.tm_yday, tm.tm_wday);
840840

841-
if (days < 0) {
841+
if days < 0 {
842842
/* This ISO week belongs to the previous year. */
843843
year -= 1;
844844
days = iso_week_days (tm.tm_yday + (days_in_year(year)), tm.tm_wday);
845845
} else {
846846
let d: int = iso_week_days (tm.tm_yday - (days_in_year(year)),
847847
tm.tm_wday);
848-
if (0 <= d) {
848+
if 0 <= d {
849849
/* This ISO week belongs to the next year. */
850850
year += 1;
851851
days = d;

src/libextra/uuid.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,16 +614,16 @@ mod test {
614614

615615
// Test error reporting
616616
let e = Uuid::parse_string("67e5504410b1426f9247bb680e5fe0c").unwrap_err();
617-
assert!(match(e){ ErrorInvalidLength(n) => n==31, _ => false });
617+
assert!(match e { ErrorInvalidLength(n) => n==31, _ => false });
618618

619619
let e = Uuid::parse_string("67e550X410b1426f9247bb680e5fe0cd").unwrap_err();
620-
assert!(match(e){ ErrorInvalidCharacter(c, n) => c=='X' && n==6, _ => false });
620+
assert!(match e { ErrorInvalidCharacter(c, n) => c=='X' && n==6, _ => false });
621621

622622
let e = Uuid::parse_string("67e550-4105b1426f9247bb680e5fe0c").unwrap_err();
623-
assert!(match(e){ ErrorInvalidGroups(n) => n==2, _ => false });
623+
assert!(match e { ErrorInvalidGroups(n) => n==2, _ => false });
624624

625625
let e = Uuid::parse_string("F9168C5E-CEB2-4faa-B6BF1-02BF39FA1E4").unwrap_err();
626-
assert!(match(e){ ErrorInvalidGroupLength(g, n, e) => g==3 && n==5 && e==4, _ => false });
626+
assert!(match e { ErrorInvalidGroupLength(g, n, e) => g==3 && n==5 && e==4, _ => false });
627627
}
628628

629629
#[test]

0 commit comments

Comments
 (0)