2014-01-18 21:57:47 -06:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-10-27 17:37:07 -05:00
|
|
|
#![deny(unused_parens)]
|
2014-01-18 21:57:47 -06:00
|
|
|
|
2014-12-30 22:32:49 -06:00
|
|
|
#[derive(Eq, PartialEq)]
|
2014-06-24 18:00:46 -05:00
|
|
|
struct X { y: bool }
|
|
|
|
impl X {
|
|
|
|
fn foo(&self) -> bool { self.y }
|
|
|
|
}
|
|
|
|
|
2014-01-18 21:57:47 -06:00
|
|
|
fn foo() -> int {
|
2014-06-27 14:30:25 -05:00
|
|
|
return (1i); //~ ERROR unnecessary parentheses around `return` value
|
2014-01-18 21:57:47 -06:00
|
|
|
}
|
2014-06-24 18:00:46 -05:00
|
|
|
fn bar() -> X {
|
|
|
|
return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value
|
|
|
|
}
|
2014-01-18 21:57:47 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo();
|
2014-06-24 18:00:46 -05:00
|
|
|
bar();
|
2014-01-18 21:57:47 -06:00
|
|
|
|
|
|
|
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
|
|
|
|
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
|
|
|
|
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
|
|
|
|
_ => {}
|
|
|
|
}
|
2014-08-25 16:55:00 -05:00
|
|
|
if let 1i = (1i) {} //~ ERROR unnecessary parentheses around `if let` head expression
|
2014-10-02 23:59:32 -05:00
|
|
|
while let 1i = (2i) {} //~ ERROR unnecessary parentheses around `while let` head expression
|
2014-06-24 18:00:46 -05:00
|
|
|
let v = X { y: false };
|
|
|
|
// struct lits needs parens, so these shouldn't warn.
|
|
|
|
if (v == X { y: true }) {}
|
|
|
|
if (X { y: true } == v) {}
|
|
|
|
if (X { y: false }.y) {}
|
|
|
|
|
|
|
|
while (X { y: false }.foo()) {}
|
|
|
|
while (true | X { y: false }.y) {}
|
|
|
|
|
|
|
|
match (X { y: false }) {
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
|
2014-06-27 14:30:25 -05:00
|
|
|
let mut _a = (0i); //~ ERROR unnecessary parentheses around assigned value
|
|
|
|
_a = (0i); //~ ERROR unnecessary parentheses around assigned value
|
|
|
|
_a += (1i); //~ ERROR unnecessary parentheses around assigned value
|
2014-01-18 21:57:47 -06:00
|
|
|
}
|