summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/precedence.txt
blob: fda0b831f335f845b67837b3e497634adfb5f95c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
### What it does
Checks for operations where precedence may be unclear
and suggests 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?
Not everyone knows the precedence of those operators by
heart, so expressions like these may trip others trying to reason about the
code.

### Example
* `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
* `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1