Skip to content

Commit 65564da

Browse files
committed
Remove extra paren
1 parent 0465958 commit 65564da

12 files changed

Lines changed: 26 additions & 29 deletions

cpp2rust/converter/converter.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,10 +2153,7 @@ bool Converter::VisitUnaryOperator(clang::UnaryOperator *expr) {
21532153
expr->getType()->isIntegerType() && !expr->getType()->isBooleanType();
21542154
PushParen paren_cast(*this, needs_int_cast);
21552155
StrCat(token::kNot);
2156-
{
2157-
PushParen paren(*this);
2158-
ConvertCondition(sub_expr);
2159-
}
2156+
ConvertCondition(sub_expr);
21602157
if (needs_int_cast) {
21612158
ConvertCast(expr->getType());
21622159
}

tests/unit/out/refcount/bool_condition_ptr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ fn main_0() -> i32 {
1616
if !(*p.borrow()).is_null() {
1717
assert!(true);
1818
}
19-
if !(!(*p.borrow()).is_null()) {
19+
if !!(*p.borrow()).is_null() {
2020
assert!(false);
2121
}
2222
if !(*np.borrow()).is_null() {
2323
assert!(false);
2424
}
25-
if !(!(*np.borrow()).is_null()) {
25+
if !!(*np.borrow()).is_null() {
2626
assert!(true);
2727
}
2828
let iter: Value<Ptr<i32>> = Rc::new(RefCell::new((*p.borrow()).clone()));
@@ -36,9 +36,9 @@ fn main_0() -> i32 {
3636
assert!(((*t3.borrow()) == 1));
3737
let t4: Value<i32> = Rc::new(RefCell::new(if !(*np.borrow()).is_null() { 1 } else { 0 }));
3838
assert!(((*t4.borrow()) == 0));
39-
let t5: Value<i32> = Rc::new(RefCell::new((!(!(*p.borrow()).is_null()) as i32)));
39+
let t5: Value<i32> = Rc::new(RefCell::new((!!(*p.borrow()).is_null() as i32)));
4040
assert!(((*t5.borrow()) == 0));
41-
let t6: Value<i32> = Rc::new(RefCell::new((!(!(*np.borrow()).is_null()) as i32)));
41+
let t6: Value<i32> = Rc::new(RefCell::new((!!(*np.borrow()).is_null() as i32)));
4242
assert!(((*t6.borrow()) == 1));
4343
let b2: Value<bool> = Rc::new(RefCell::new((!(*p.borrow()).is_null()).clone()));
4444
let b3: Value<bool> = Rc::new(RefCell::new((!(*np.borrow()).is_null()).clone()));

tests/unit/out/refcount/bool_condition_ptr_c.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ fn main_0() -> i32 {
1616
if !(*p.borrow()).is_null() {
1717
assert!((1 != 0));
1818
}
19-
if !(!(*p.borrow()).is_null()) {
19+
if !!(*p.borrow()).is_null() {
2020
assert!((0 != 0));
2121
}
2222
if !(*np.borrow()).is_null() {
2323
assert!((0 != 0));
2424
}
25-
if !(!(*np.borrow()).is_null()) {
25+
if !!(*np.borrow()).is_null() {
2626
assert!((1 != 0));
2727
}
2828
let iter: Value<Ptr<i32>> = Rc::new(RefCell::new((*p.borrow()).clone()));
@@ -36,9 +36,9 @@ fn main_0() -> i32 {
3636
assert!(((*t3.borrow()) == 1));
3737
let t4: Value<i32> = Rc::new(RefCell::new(if !(*np.borrow()).is_null() { 1 } else { 0 }));
3838
assert!(((*t4.borrow()) == 0));
39-
let t5: Value<i32> = Rc::new(RefCell::new((!(!(*p.borrow()).is_null()) as i32)));
39+
let t5: Value<i32> = Rc::new(RefCell::new((!!(*p.borrow()).is_null() as i32)));
4040
assert!(((*t5.borrow()) == 0));
41-
let t6: Value<i32> = Rc::new(RefCell::new((!(!(*np.borrow()).is_null()) as i32)));
41+
let t6: Value<i32> = Rc::new(RefCell::new((!!(*np.borrow()).is_null() as i32)));
4242
assert!(((*t6.borrow()) == 1));
4343
let b2: Value<bool> = Rc::new(RefCell::new((!(*p.borrow()).is_null()).clone()));
4444
let b3: Value<bool> = Rc::new(RefCell::new((!(*np.borrow()).is_null()).clone()));

tests/unit/out/refcount/fn_ptr_as_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main_0() -> i32 {
4343
});
4444
assert!(((*b.borrow()) == 5));
4545
let fn_: Value<FnPtr<fn(Ptr<i32>)>> = Rc::new(RefCell::new(FnPtr::null()));
46-
if !(!(*fn_.borrow()).is_null()) {
46+
if !!(*fn_.borrow()).is_null() {
4747
(*fn_.borrow_mut()) = FnPtr::<fn(Ptr<i32>)>::new(double_it_0);
4848
}
4949
let c: Value<i32> = Rc::new(RefCell::new(3));

tests/unit/out/refcount/vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main_0() -> i32 {
1717
assert!(((*v1.borrow()).len() as u64 == 0_u64));
1818
assert!((*v1.borrow()).is_empty());
1919
(*v1.borrow_mut()).push(1);
20-
assert!(!((*v1.borrow()).is_empty()));
20+
assert!(!(*v1.borrow()).is_empty());
2121
(*v1.borrow_mut()).pop();
2222
assert!((*v1.borrow()).is_empty());
2323
let s1: Value<u64> = Rc::new(RefCell::new((*v1.borrow()).len() as u64));

tests/unit/out/unsafe/bool_condition_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ unsafe fn main_0() -> i32 {
4646
let mut t9: i32 = (!(code != Code::from(0)) as i32);
4747
assert!(((t9) == (1)));
4848
let mut b4: bool = (code != Code::from(0));
49-
assert!(!(b4));
49+
assert!(!b4);
5050
return 0;
5151
}

tests/unit/out/unsafe/bool_condition_enum_c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ unsafe fn main_0() -> i32 {
4646
let mut t9: i32 = (!(code != Code::from(0)) as i32);
4747
assert!(((t9) == (1)));
4848
let mut b4: bool = (code != Code::from(0));
49-
assert!(((!(b4) as i32) != 0));
49+
assert!(((!b4 as i32) != 0));
5050
return 0;
5151
}

tests/unit/out/unsafe/bool_condition_ptr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ unsafe fn main_0() -> i32 {
1818
if !(p).is_null() {
1919
assert!(true);
2020
}
21-
if !(!(p).is_null()) {
21+
if !!(p).is_null() {
2222
assert!(false);
2323
}
2424
if !(np).is_null() {
2525
assert!(false);
2626
}
27-
if !(!(np).is_null()) {
27+
if !!(np).is_null() {
2828
assert!(true);
2929
}
3030
let mut iter: *mut i32 = p;
@@ -38,13 +38,13 @@ unsafe fn main_0() -> i32 {
3838
assert!(((t3) == (1)));
3939
let mut t4: i32 = if !(np).is_null() { 1 } else { 0 };
4040
assert!(((t4) == (0)));
41-
let mut t5: i32 = (!(!(p).is_null()) as i32);
41+
let mut t5: i32 = (!!(p).is_null() as i32);
4242
assert!(((t5) == (0)));
43-
let mut t6: i32 = (!(!(np).is_null()) as i32);
43+
let mut t6: i32 = (!!(np).is_null() as i32);
4444
assert!(((t6) == (1)));
4545
let mut b2: bool = !(p).is_null();
4646
let mut b3: bool = !(np).is_null();
4747
assert!(b2);
48-
assert!(!(b3));
48+
assert!(!b3);
4949
return 0;
5050
}

tests/unit/out/unsafe/bool_condition_ptr_c.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ unsafe fn main_0() -> i32 {
1818
if !(p).is_null() {
1919
assert!((1 != 0));
2020
}
21-
if !(!(p).is_null()) {
21+
if !!(p).is_null() {
2222
assert!((0 != 0));
2323
}
2424
if !(np).is_null() {
2525
assert!((0 != 0));
2626
}
27-
if !(!(np).is_null()) {
27+
if !!(np).is_null() {
2828
assert!((1 != 0));
2929
}
3030
let mut iter: *mut i32 = p;
@@ -38,13 +38,13 @@ unsafe fn main_0() -> i32 {
3838
assert!(((t3) == (1)));
3939
let mut t4: i32 = if !(np).is_null() { 1 } else { 0 };
4040
assert!(((t4) == (0)));
41-
let mut t5: i32 = (!(!(p).is_null()) as i32);
41+
let mut t5: i32 = (!!(p).is_null() as i32);
4242
assert!(((t5) == (0)));
43-
let mut t6: i32 = (!(!(np).is_null()) as i32);
43+
let mut t6: i32 = (!!(np).is_null() as i32);
4444
assert!(((t6) == (1)));
4545
let mut b2: bool = !(p).is_null();
4646
let mut b3: bool = !(np).is_null();
4747
assert!(b2);
48-
assert!(((!(b3) as i32) != 0));
48+
assert!(((!b3 as i32) != 0));
4949
return 0;
5050
}

tests/unit/out/unsafe/fn_ptr_as_condition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ unsafe fn main_0() -> i32 {
3838
});
3939
assert!(((b) == (5)));
4040
let mut fn_: Option<unsafe fn(*mut i32)> = None;
41-
if !(!(fn_).is_none()) {
41+
if !!(fn_).is_none() {
4242
fn_ = Some(double_it_0);
4343
}
4444
let mut c: i32 = 3;

0 commit comments

Comments
 (0)