Bugfix + add test.

This commit is contained in:
laurent 2017-11-17 21:52:11 +00:00
parent 8e9d0c277c
commit ed202b6055
3 changed files with 9 additions and 7 deletions

View File

@ -218,13 +218,8 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
self.output.push_str(&str) self.output.push_str(&str)
} else { } else {
self.output.push('!'); self.output.push('!');
if let ExprBinary(..) = terminal.node { let snip = self.snip(terminal);
self.output.push('('); self.output.push_str(&snip);
}
self.recurse(inner);
if let ExprBinary(..) = terminal.node {
self.output.push(';');
}
} }
}, },
True | False | Not(_) => { True | False | Not(_) => {

View File

@ -53,4 +53,5 @@ fn methods_with_negation() {
let _ = !b.is_ok(); let _ = !b.is_ok();
let c = false; let c = false;
let _ = !(a.is_some() && !c); let _ = !(a.is_some() && !c);
let _ = !(!c ^ c) || !a.is_some();
} }

View File

@ -160,3 +160,9 @@ error: this boolean expression can be simplified
55 | let _ = !(a.is_some() && !c); 55 | let _ = !(a.is_some() && !c);
| ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()` | ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:56:13
|
56 | let _ = !(!c ^ c) || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()`