]> git.lizzy.rs Git - rust.git/blob - src/docs/precedence.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / precedence.txt
1 ### What it does
2 Checks for operations where precedence may be unclear
3 and suggests to add parentheses. Currently it catches the following:
4 * mixed usage of arithmetic and bit shifting/combining operators without
5 parentheses
6 * a "negative" numeric literal (which is really a unary `-` followed by a
7 numeric literal)
8   followed by a method call
9
10 ### Why is this bad?
11 Not everyone knows the precedence of those operators by
12 heart, so expressions like these may trip others trying to reason about the
13 code.
14
15 ### Example
16 * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
17 * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1