11use crate :: utils:: {
2- match_def_path, match_trait_method, paths, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_then ,
2+ match_def_path, match_trait_method, paths, same_tys, snippet, snippet_with_macro_callsite, span_lint_and_sugg ,
33} ;
44use rustc_errors:: Applicability ;
55use rustc_hir:: { Expr , ExprKind , HirId , MatchSource } ;
@@ -58,29 +58,31 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
5858 if same_tys ( cx, a, b) {
5959 let sugg = snippet_with_macro_callsite ( cx, args[ 0 ] . span , "<expr>" ) . to_string ( ) ;
6060
61- span_lint_and_then ( cx, IDENTITY_CONVERSION , e. span , "identical conversion" , |diag| {
62- diag. span_suggestion (
63- e. span ,
64- "consider removing `.into()`" ,
65- sugg,
66- Applicability :: MachineApplicable , // snippet
67- ) ;
68- } ) ;
61+ span_lint_and_sugg (
62+ cx,
63+ IDENTITY_CONVERSION ,
64+ e. span ,
65+ "identical conversion" ,
66+ "consider removing `.into()`" ,
67+ sugg,
68+ Applicability :: MachineApplicable , // snippet
69+ ) ;
6970 }
7071 }
7172 if match_trait_method ( cx, e, & paths:: INTO_ITERATOR ) && & * name. ident . as_str ( ) == "into_iter" {
7273 let a = cx. tables . expr_ty ( e) ;
7374 let b = cx. tables . expr_ty ( & args[ 0 ] ) ;
7475 if same_tys ( cx, a, b) {
7576 let sugg = snippet ( cx, args[ 0 ] . span , "<expr>" ) . into_owned ( ) ;
76- span_lint_and_then ( cx, IDENTITY_CONVERSION , e. span , "identical conversion" , |diag| {
77- diag. span_suggestion (
78- e. span ,
79- "consider removing `.into_iter()`" ,
80- sugg,
81- Applicability :: MachineApplicable , // snippet
82- ) ;
83- } ) ;
77+ span_lint_and_sugg (
78+ cx,
79+ IDENTITY_CONVERSION ,
80+ e. span ,
81+ "identical conversion" ,
82+ "consider removing `.into_iter()`" ,
83+ sugg,
84+ Applicability :: MachineApplicable , // snippet
85+ ) ;
8486 }
8587 }
8688 } ,
@@ -95,14 +97,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
9597 let sugg = snippet ( cx, args[ 0 ] . span . source_callsite ( ) , "<expr>" ) . into_owned ( ) ;
9698 let sugg_msg =
9799 format ! ( "consider removing `{}()`" , snippet( cx, path. span, "From::from" ) ) ;
98- span_lint_and_then ( cx, IDENTITY_CONVERSION , e. span , "identical conversion" , |diag| {
99- diag. span_suggestion (
100- e. span ,
101- & sugg_msg,
102- sugg,
103- Applicability :: MachineApplicable , // snippet
104- ) ;
105- } ) ;
100+ span_lint_and_sugg (
101+ cx,
102+ IDENTITY_CONVERSION ,
103+ e. span ,
104+ "identical conversion" ,
105+ & sugg_msg,
106+ sugg,
107+ Applicability :: MachineApplicable , // snippet
108+ ) ;
106109 }
107110 }
108111 }
0 commit comments