@@ -328,16 +328,17 @@ impl<'tcx> LateLintPass<'tcx> for TypeIr {
328328 fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx hir:: Item < ' tcx > ) {
329329 let rustc_hir:: ItemKind :: Use ( path, kind) = item. kind else { return } ;
330330
331- let is_mod_inherent = |def_id| cx. tcx . is_diagnostic_item ( sym:: type_ir_inherent, def_id) ;
331+ let is_mod_inherent = |res : Res | {
332+ res. opt_def_id ( )
333+ . is_some_and ( |def_id| cx. tcx . is_diagnostic_item ( sym:: type_ir_inherent, def_id) )
334+ } ;
332335
333336 // Path segments except for the final.
334- if let Some ( seg) =
335- path. segments . iter ( ) . find ( |seg| seg. res . opt_def_id ( ) . is_some_and ( is_mod_inherent) )
336- {
337+ if let Some ( seg) = path. segments . iter ( ) . find ( |seg| is_mod_inherent ( seg. res ) ) {
337338 cx. emit_span_lint ( USAGE_OF_TYPE_IR_INHERENT , seg. ident . span , TypeIrInherentUsage ) ;
338339 }
339340 // Final path resolutions, like `use rustc_type_ir::inherent`
340- else if path. res . iter ( ) . any ( |res| res . opt_def_id ( ) . is_some_and ( is_mod_inherent) ) {
341+ else if path. res . iter ( ) . any ( |& res| is_mod_inherent ( res ) ) {
341342 cx. emit_span_lint (
342343 USAGE_OF_TYPE_IR_INHERENT ,
343344 path. segments . last ( ) . unwrap ( ) . ident . span ,
@@ -346,13 +347,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeIr {
346347 }
347348
348349 let ( lo, hi, snippet) = match path. segments {
349- [ .., penultimate, segment]
350- if penultimate. res . opt_def_id ( ) . is_some_and ( is_mod_inherent) =>
351- {
350+ [ .., penultimate, segment] if is_mod_inherent ( penultimate. res ) => {
352351 ( segment. ident . span , item. kind . ident ( ) . unwrap ( ) . span , "*" )
353352 }
354353 [ .., segment]
355- if path. res . iter ( ) . flat_map ( Res :: opt_def_id ) . any ( is_mod_inherent)
354+ if path. res . iter ( ) . any ( | & res| is_mod_inherent ( res ) )
356355 && let rustc_hir:: UseKind :: Single ( ident) = kind =>
357356 {
358357 let ( lo, snippet) =
0 commit comments