added wiki comments + wiki-generating python script
This commit is contained in:
parent
2fbe762a99
commit
5bbc1427fd
28 changed files with 668 additions and 0 deletions
|
|
@ -5,6 +5,17 @@ use syntax::ast_util::binop_to_string;
|
|||
|
||||
use utils::{span_lint, snippet};
|
||||
|
||||
/// **What it does:** This lint checks for operations where precedence may be unclear and `Warn`'s about them by default, suggesting to add parentheses. Currently it catches the following:
|
||||
/// * mixed usage of arithmetic and bit shifting/combining operators without parentheses
|
||||
/// * a "negative" numeric literal (which is really a unary `-` followed by a numeric literal) followed by a method call
|
||||
///
|
||||
/// **Why is this bad?** Because not everyone knows the precedence of those operators by heart, so expressions like these may trip others trying to reason about the code.
|
||||
///
|
||||
/// **Known problems:** None
|
||||
///
|
||||
/// **Examples:**
|
||||
/// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
|
||||
/// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1
|
||||
declare_lint!(pub PRECEDENCE, Warn,
|
||||
"catches operations where precedence may be unclear. See the wiki for a \
|
||||
list of cases caught");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue