From 9982de6397197a63a093e7b79851d1915ef783d7 Mon Sep 17 00:00:00 2001 From: Eduard Bopp Date: Tue, 18 Feb 2014 13:40:25 +0100 Subject: Warn about unnecessary parentheses upon assignment Closes #12366. Parentheses around assignment statements such as let mut a = (0); a = (1); a += (2); are not necessary and therefore an unnecessary_parens warning is raised when statements like this occur. The warning mechanism was refactored along the way to allow for code reuse between the routines for checking expressions and statements. Code had to be adopted throughout the compiler and standard libraries to comply with this modification of the lint. --- src/libsyntax/abi.rs | 2 +- src/libsyntax/ast.rs | 2 +- src/libsyntax/diagnostic.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 6b0f2c6e516..82e4d08d077 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -202,7 +202,7 @@ impl AbiSet { } pub fn add(&mut self, abi: Abi) { - self.bits |= (1 << abi.index()); + self.bits |= 1 << abi.index(); } pub fn each(&self, op: |abi: Abi| -> bool) -> bool { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e8edc1a0dfc..c436dc018e7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1224,6 +1224,6 @@ mod test { }, }; // doesn't matter which encoder we use.... - let _f = (&e as &serialize::Encodable); + let _f = &e as &serialize::Encodable; } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 9455df063f1..8cf0f128d22 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -329,7 +329,7 @@ fn highlight_lines(cm: &codemap::CodeMap, for _ in range(0, skip) { s.push_char(' '); } let orig = fm.get_line(lines.lines[0] as int); for pos in range(0u, left-skip) { - let curChar = (orig[pos] as char); + let curChar = orig[pos] as char; // Whenever a tab occurs on the previous line, we insert one on // the error-point-squiggly-line as well (instead of a space). // That way the squiggly line will usually appear in the correct -- cgit 1.4.1-3-g733a5