]> git.lizzy.rs Git - rust.git/blob - src/docs/deref_addrof.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / deref_addrof.txt
1 ### What it does
2 Checks for usage of `*&` and `*&mut` in expressions.
3
4 ### Why is this bad?
5 Immediately dereferencing a reference is no-op and
6 makes the code less clear.
7
8 ### Known problems
9 Multiple dereference/addrof pairs are not handled so
10 the suggested fix for `x = **&&y` is `x = *&y`, which is still incorrect.
11
12 ### Example
13 ```
14 let a = f(*&mut b);
15 let c = *&d;
16 ```
17
18 Use instead:
19 ```
20 let a = f(b);
21 let c = d;
22 ```