@@ -386,12 +386,13 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
386386
387387 ExprKind :: Call ( path, [ arg] ) => {
388388 if let ExprKind :: Path ( ref qpath) = path. kind
389- && let Some ( def_id) = cx. qpath_res ( qpath, path. hir_id ) . opt_def_id ( )
390389 && !is_ty_alias ( qpath)
390+ && let Some ( def_id) = cx. qpath_res ( qpath, path. hir_id ) . opt_def_id ( )
391+ && let Some ( name) = cx. tcx . get_diagnostic_name ( def_id)
391392 {
392393 let a = cx. typeck_results ( ) . expr_ty ( e) ;
393394 let b = cx. typeck_results ( ) . expr_ty ( arg) ;
394- if cx . tcx . is_diagnostic_item ( sym:: try_from_fn, def_id )
395+ if name == sym:: try_from_fn
395396 && is_type_diagnostic_item ( cx, a, sym:: Result )
396397 && let ty:: Adt ( _, args) = a. kind ( )
397398 && let Some ( a_type) = args. types ( ) . next ( )
@@ -406,9 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
406407 None ,
407408 hint,
408409 ) ;
409- }
410-
411- if cx. tcx . is_diagnostic_item ( sym:: from_fn, def_id) && same_type_and_consts ( a, b) {
410+ } else if name == sym:: from_fn && same_type_and_consts ( a, b) {
412411 let mut app = Applicability :: MachineApplicable ;
413412 let sugg = Sugg :: hir_with_context ( cx, arg, e. span . ctxt ( ) , "<expr>" , & mut app) . maybe_paren ( ) ;
414413 let sugg_msg = format ! ( "consider removing `{}()`" , snippet( cx, path. span, "From::from" ) ) ;
0 commit comments