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(
1616 span : Span ,
1717 _hir_id : HirId ,
1818) {
19- let FnKind :: Method ( ref ident, sig ) = kind else {
19+ let FnKind :: Method ( ref ident, _ ) = kind else {
2020 return ;
2121 } ;
2222
@@ -27,7 +27,7 @@ pub fn check_fn(
2727
2828 let name = ident. name . as_str ( ) ;
2929
30- let name = match sig . decl . implicit_self {
30+ let name = match decl. implicit_self {
3131 ImplicitSelfKind :: MutRef => {
3232 let Some ( name) = name. strip_suffix ( "_mut" ) else {
3333 return ;
@@ -53,11 +53,12 @@ pub fn check_fn(
5353 } ;
5454 let expr_span = block_expr. span ;
5555
56- let mut expr = block_expr;
5756 // 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+ } ;
6162 let ( self_data, used_ident) = if_chain ! {
6263 if let ExprKind :: Field ( self_data, ident) = expr. kind;
6364 if ident. name. as_str( ) != name;
Original file line number Diff line number Diff line change @@ -60,6 +60,29 @@ impl B {
6060 unsafe fn c_mut ( & mut self ) -> & mut u8 {
6161 & mut self . a
6262 }
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+ }
6386}
6487
6588fn main ( ) {
You can’t perform that action at this time.
0 commit comments