@@ -62,13 +62,11 @@ mod zst_offset;
6262use bind_instead_of_map:: BindInsteadOfMap ;
6363use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
6464use clippy_utils:: ty:: { contains_ty, implements_trait, is_copy, is_type_diagnostic_item} ;
65- use clippy_utils:: {
66- contains_return, get_trait_def_id, in_macro, iter_input_pats, match_qpath, method_calls, paths, return_ty,
67- SpanlessEq ,
68- } ;
65+ use clippy_utils:: { contains_return, get_trait_def_id, in_macro, iter_input_pats, method_calls, paths, return_ty} ;
6966use if_chain:: if_chain;
7067use rustc_hir as hir;
71- use rustc_hir:: { TraitItem , TraitItemKind } ;
68+ use rustc_hir:: def:: Res ;
69+ use rustc_hir:: { PrimTy , QPath , TraitItem , TraitItemKind } ;
7270use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
7371use rustc_middle:: lint:: in_external_macro;
7472use rustc_middle:: ty:: { self , TraitRef , Ty , TyS } ;
@@ -1872,7 +1870,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
18721870 for method_config in & TRAIT_METHODS {
18731871 if name == method_config. method_name &&
18741872 sig. decl. inputs. len( ) == method_config. param_count &&
1875- method_config. output_type. matches( cx , & sig. decl. output) &&
1873+ method_config. output_type. matches( & sig. decl. output) &&
18761874 method_config. self_kind. matches( cx, self_ty, first_arg_ty) &&
18771875 fn_header_equals( method_config. fn_header, sig. header) &&
18781876 method_config. lifetime_param_cond( & impl_item)
@@ -2199,8 +2197,8 @@ enum OutType {
21992197}
22002198
22012199impl OutType {
2202- fn matches ( self , cx : & LateContext < ' _ > , ty : & hir:: FnRetTy < ' _ > ) -> bool {
2203- let is_unit = |ty : & hir:: Ty < ' _ > | SpanlessEq :: new ( cx ) . eq_ty_kind ( & ty. kind , & hir:: TyKind :: Tup ( & [ ] ) ) ;
2200+ fn matches ( self , ty : & hir:: FnRetTy < ' _ > ) -> bool {
2201+ let is_unit = |ty : & hir:: Ty < ' _ > | matches ! ( ty. kind, hir:: TyKind :: Tup ( & [ ] ) ) ;
22042202 match ( self , ty) {
22052203 ( Self :: Unit , & hir:: FnRetTy :: DefaultReturn ( _) ) => true ,
22062204 ( Self :: Unit , & hir:: FnRetTy :: Return ( ref ty) ) if is_unit ( ty) => true ,
@@ -2213,8 +2211,8 @@ impl OutType {
22132211}
22142212
22152213fn is_bool ( ty : & hir:: Ty < ' _ > ) -> bool {
2216- if let hir:: TyKind :: Path ( ref p ) = ty. kind {
2217- match_qpath ( p , & [ "bool" ] )
2214+ if let hir:: TyKind :: Path ( QPath :: Resolved ( _ , path ) ) = ty. kind {
2215+ matches ! ( path . res , Res :: PrimTy ( PrimTy :: Bool ) )
22182216 } else {
22192217 false
22202218 }
0 commit comments