File tree Expand file tree Collapse file tree 2 files changed +30
-6
lines changed
clippy_lints/src/functions Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ pub fn check_fn(
16
16
span : Span ,
17
17
_hir_id : HirId ,
18
18
) {
19
- let FnKind :: Method ( ref ident, sig ) = kind else {
19
+ let FnKind :: Method ( ref ident, _ ) = kind else {
20
20
return ;
21
21
} ;
22
22
@@ -27,7 +27,7 @@ pub fn check_fn(
27
27
28
28
let name = ident. name . as_str ( ) ;
29
29
30
- let name = match sig . decl . implicit_self {
30
+ let name = match decl. implicit_self {
31
31
ImplicitSelfKind :: MutRef => {
32
32
let Some ( name) = name. strip_suffix ( "_mut" ) else {
33
33
return ;
@@ -53,11 +53,12 @@ pub fn check_fn(
53
53
} ;
54
54
let expr_span = block_expr. span ;
55
55
56
- let mut expr = block_expr;
57
56
// Accept &<expr>, &mut <expr> and <expr>
58
- if let ExprKind :: AddrOf ( _, _, tmp) = expr. kind {
59
- expr = tmp;
60
- }
57
+ let expr = if let ExprKind :: AddrOf ( _, _, tmp) = block_expr. kind {
58
+ tmp
59
+ } else {
60
+ block_expr
61
+ } ;
61
62
let ( self_data, used_ident) = if_chain ! {
62
63
if let ExprKind :: Field ( self_data, ident) = expr. kind;
63
64
if ident. name. as_str( ) != name;
Original file line number Diff line number Diff line change @@ -60,6 +60,29 @@ impl B {
60
60
unsafe fn c_mut ( & mut self ) -> & mut u8 {
61
61
& mut self . a
62
62
}
63
+
64
+ unsafe fn a_unchecked ( & self ) -> & u8 {
65
+ & self . b
66
+ }
67
+ unsafe fn a_unchecked_mut ( & mut self ) -> & mut u8 {
68
+ & mut self . b
69
+ }
70
+
71
+ unsafe fn b_unchecked ( self ) -> u8 {
72
+ self . a
73
+ }
74
+
75
+ unsafe fn b_unchecked_mut ( & mut self ) -> & mut u8 {
76
+ & mut self . a
77
+ }
78
+
79
+ unsafe fn c_unchecked ( & self ) -> & u8 {
80
+ & self . b
81
+ }
82
+
83
+ unsafe fn c_unchecked_mut ( & mut self ) -> & mut u8 {
84
+ & mut self . a
85
+ }
63
86
}
64
87
65
88
fn main ( ) {
You can’t perform that action at this time.
0 commit comments