@@ -355,24 +355,26 @@ fn parse_len_output<'tcx>(cx: &LateContext<'tcx>, sig: FnSig<'tcx>) -> Option<Le
355
355
return Some ( LenOutput :: Integral ) ;
356
356
}
357
357
358
- if let Res :: Def ( _, def_id) = res {
359
- if cx. tcx . is_diagnostic_item ( sym :: Option , def_id) && is_first_generic_integral ( segment ) {
360
- return Some ( LenOutput :: Option ( def_id) ) ;
361
- } else if cx . tcx . is_diagnostic_item ( sym:: Result , def_id ) && is_first_generic_integral ( segment ) {
362
- return Some ( LenOutput :: Result ( def_id ) ) ;
358
+ if let Res :: Def ( _, def_id) = res
359
+ && let Some ( res ) = match cx. tcx . get_diagnostic_name ( def_id) {
360
+ Some ( sym :: Option ) => Some ( LenOutput :: Option ( def_id) ) ,
361
+ Some ( sym:: Result ) => Some ( LenOutput :: Result ( def_id ) ) ,
362
+ _ => None ,
363
363
}
364
+ && is_first_generic_integral ( segment)
365
+ {
366
+ return Some ( res) ;
364
367
}
365
368
366
369
return None ;
367
370
}
368
371
369
372
match * sig. output ( ) . kind ( ) {
370
373
ty:: Int ( _) | ty:: Uint ( _) => Some ( LenOutput :: Integral ) ,
371
- ty:: Adt ( adt, subs) if cx. tcx . is_diagnostic_item ( sym:: Option , adt. did ( ) ) => {
372
- subs. type_at ( 0 ) . is_integral ( ) . then ( || LenOutput :: Option ( adt. did ( ) ) )
373
- } ,
374
- ty:: Adt ( adt, subs) if cx. tcx . is_diagnostic_item ( sym:: Result , adt. did ( ) ) => {
375
- subs. type_at ( 0 ) . is_integral ( ) . then ( || LenOutput :: Result ( adt. did ( ) ) )
374
+ ty:: Adt ( adt, subs) => match cx. tcx . get_diagnostic_name ( adt. did ( ) ) {
375
+ Some ( sym:: Option ) => subs. type_at ( 0 ) . is_integral ( ) . then ( || LenOutput :: Option ( adt. did ( ) ) ) ,
376
+ Some ( sym:: Result ) => subs. type_at ( 0 ) . is_integral ( ) . then ( || LenOutput :: Result ( adt. did ( ) ) ) ,
377
+ _ => None ,
376
378
} ,
377
379
_ => None ,
378
380
}
0 commit comments