]> git.lizzy.rs Git - rust.git/blob - tests/ui/deref_addrof.fixed
return_self_not_must_use document `#[must_use]` on the type
[rust.git] / tests / ui / deref_addrof.fixed
1 // run-rustfix
2 #![allow(clippy::return_self_not_must_use)]
3 #![warn(clippy::deref_addrof)]
4
5 fn get_number() -> usize {
6     10
7 }
8
9 fn get_reference(n: &usize) -> &usize {
10     n
11 }
12
13 #[allow(clippy::double_parens)]
14 #[allow(unused_variables, unused_parens)]
15 fn main() {
16     let a = 10;
17     let aref = &a;
18
19     let b = a;
20
21     let b = get_number();
22
23     let b = *get_reference(&a);
24
25     let bytes: Vec<usize> = vec![1, 2, 3, 4];
26     let b = bytes[1..2][0];
27
28     //This produces a suggestion of 'let b = (a);' which
29     //will trigger the 'unused_parens' lint
30     let b = (a);
31
32     let b = a;
33
34     #[rustfmt::skip]
35     let b = a;
36
37     let b = &a;
38
39     let b = *aref;
40 }
41
42 #[rustfmt::skip]
43 macro_rules! m {
44     ($visitor: expr) => {
45         $visitor
46     };
47 }
48
49 #[rustfmt::skip]
50 macro_rules! m_mut {
51     ($visitor: expr) => {
52         $visitor
53     };
54 }
55
56 #[derive(Copy, Clone)]
57 pub struct S;
58 impl S {
59     pub fn f(&self) -> &Self {
60         m!(self)
61     }
62     #[allow(unused_mut)] // mut will be unused, once the macro is fixed
63     pub fn f_mut(mut self) -> Self {
64         m_mut!(self)
65     }
66 }