1
1
// SPDX-License-Identifier: Apache-2.0 OR MIT
2
2
3
3
use proc_macro2:: { Span , TokenStream } ;
4
- use quote:: { format_ident , quote , ToTokens as _} ;
4
+ use quote:: { ToTokens as _, format_ident , quote } ;
5
5
use syn:: {
6
- parse_quote , spanned :: Spanned as _ , token :: Colon , visit_mut :: VisitMut as _ , Error , FnArg ,
7
- GenericArgument , Ident , ImplItem , ItemImpl , Pat , PatIdent , PatType , Path , PathArguments ,
8
- Result , ReturnType , Signature , Token , Type , TypePath , TypeReference ,
6
+ Error , FnArg , GenericArgument , Ident , ImplItem , ItemImpl , Pat , PatIdent , PatType , Path ,
7
+ PathArguments , Result , ReturnType , Signature , Token , Type , TypePath , TypeReference ,
8
+ parse_quote , spanned :: Spanned as _ , token :: Colon , visit_mut :: VisitMut as _ ,
9
9
} ;
10
10
11
11
use crate :: utils:: { ReplaceReceiver , SliceExt as _} ;
@@ -91,11 +91,7 @@ fn validate_impl(item: &ItemImpl) -> Result<()> {
91
91
}
92
92
ImplItem :: Fn ( method) => {
93
93
validate_sig ( & method. sig ) ?;
94
- if i == 0 {
95
- Ok ( ( ) )
96
- } else {
97
- bail ! ( method, "duplicate definitions with name `drop`" )
98
- }
94
+ if i == 0 { Ok ( ( ) ) } else { bail ! ( method, "duplicate definitions with name `drop`" ) }
99
95
}
100
96
_ => unreachable ! ( "unexpected ImplItem" ) ,
101
97
} )
@@ -106,11 +102,7 @@ fn validate_impl(item: &ItemImpl) -> Result<()> {
106
102
/// The correct signature is: `(mut) self: (<path>::)Pin<&mut Self>`
107
103
fn validate_sig ( sig : & Signature ) -> Result < ( ) > {
108
104
fn get_ty_path ( ty : & Type ) -> Option < & Path > {
109
- if let Type :: Path ( TypePath { qself : None , path } ) = ty {
110
- Some ( path)
111
- } else {
112
- None
113
- }
105
+ if let Type :: Path ( TypePath { qself : None , path } ) = ty { Some ( path) } else { None }
114
106
}
115
107
116
108
const INVALID_ARGUMENT : & str = "method `drop` must take an argument `self: Pin<&mut Self>`" ;
0 commit comments