@@ -386,12 +386,13 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
386
386
387
387
ExprKind :: Call ( path, [ arg] ) => {
388
388
if let ExprKind :: Path ( ref qpath) = path. kind
389
- && let Some ( def_id) = cx. qpath_res ( qpath, path. hir_id ) . opt_def_id ( )
390
389
&& !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)
391
392
{
392
393
let a = cx. typeck_results ( ) . expr_ty ( e) ;
393
394
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
395
396
&& is_type_diagnostic_item ( cx, a, sym:: Result )
396
397
&& let ty:: Adt ( _, args) = a. kind ( )
397
398
&& let Some ( a_type) = args. types ( ) . next ( )
@@ -406,9 +407,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
406
407
None ,
407
408
hint,
408
409
) ;
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) {
412
411
let mut app = Applicability :: MachineApplicable ;
413
412
let sugg = Sugg :: hir_with_context ( cx, arg, e. span . ctxt ( ) , "<expr>" , & mut app) . maybe_paren ( ) ;
414
413
let sugg_msg = format ! ( "consider removing `{}()`" , snippet( cx, path. span, "From::from" ) ) ;
0 commit comments