@@ -328,16 +328,17 @@ impl<'tcx> LateLintPass<'tcx> for TypeIr {
328
328
fn check_item ( & mut self , cx : & LateContext < ' tcx > , item : & ' tcx hir:: Item < ' tcx > ) {
329
329
let rustc_hir:: ItemKind :: Use ( path, kind) = item. kind else { return } ;
330
330
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
+ } ;
332
335
333
336
// 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 ) ) {
337
338
cx. emit_span_lint ( USAGE_OF_TYPE_IR_INHERENT , seg. ident . span , TypeIrInherentUsage ) ;
338
339
}
339
340
// 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 ) ) {
341
342
cx. emit_span_lint (
342
343
USAGE_OF_TYPE_IR_INHERENT ,
343
344
path. segments . last ( ) . unwrap ( ) . ident . span ,
@@ -346,13 +347,11 @@ impl<'tcx> LateLintPass<'tcx> for TypeIr {
346
347
}
347
348
348
349
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 ) => {
352
351
( segment. ident . span , item. kind . ident ( ) . unwrap ( ) . span , "*" )
353
352
}
354
353
[ .., 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 ) )
356
355
&& let rustc_hir:: UseKind :: Single ( ident) = kind =>
357
356
{
358
357
let ( lo, snippet) =
0 commit comments