@@ -180,8 +180,7 @@ crate fn placeholder_type_error(
180180 // Suggest, but only if it is not a function in const or static
181181 if suggest {
182182 let mut is_fn = false ;
183- let mut is_const = false ;
184- let mut is_static = false ;
183+ let mut is_const_or_static = false ;
185184
186185 if let Some ( hir_ty) = hir_ty {
187186 if let hir:: TyKind :: BareFn ( _) = hir_ty. kind {
@@ -191,19 +190,26 @@ crate fn placeholder_type_error(
191190 let parent_id = tcx. hir ( ) . get_parent_node ( hir_ty. hir_id ) ;
192191 let parent_node = tcx. hir ( ) . get ( parent_id) ;
193192
194- if let hir:: Node :: Item ( item) = parent_node {
195- if let hir:: ItemKind :: Const ( _, _) = item. kind {
196- is_const = true ;
197- } else if let hir:: ItemKind :: Static ( _, _, _) = item. kind {
198- is_static = true ;
199- }
200- }
193+ is_const_or_static = match parent_node {
194+ Node :: Item ( & hir:: Item {
195+ kind : hir:: ItemKind :: Const ( ..) | hir:: ItemKind :: Static ( ..) ,
196+ ..
197+ } )
198+ | Node :: TraitItem ( & hir:: TraitItem {
199+ kind : hir:: TraitItemKind :: Const ( ..) ,
200+ ..
201+ } )
202+ | Node :: ImplItem ( & hir:: ImplItem {
203+ kind : hir:: ImplItemKind :: Const ( ..) , ..
204+ } ) => true ,
205+ _ => false ,
206+ } ;
201207 }
202208 }
203209
204210 // if function is wrapped around a const or static,
205211 // then don't show the suggestion
206- if !( is_fn && ( is_const || is_static ) ) {
212+ if !( is_fn && is_const_or_static ) {
207213 err. multipart_suggestion (
208214 "use type parameters instead" ,
209215 sugg,
0 commit comments