1
1
use 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 ,
3
3
} ;
4
4
use rustc_errors:: Applicability ;
5
5
use rustc_hir:: { Expr , ExprKind , HirId , MatchSource } ;
@@ -58,29 +58,31 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
58
58
if same_tys ( cx, a, b) {
59
59
let sugg = snippet_with_macro_callsite ( cx, args[ 0 ] . span , "<expr>" ) . to_string ( ) ;
60
60
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
+ ) ;
69
70
}
70
71
}
71
72
if match_trait_method ( cx, e, & paths:: INTO_ITERATOR ) && & * name. ident . as_str ( ) == "into_iter" {
72
73
let a = cx. tables . expr_ty ( e) ;
73
74
let b = cx. tables . expr_ty ( & args[ 0 ] ) ;
74
75
if same_tys ( cx, a, b) {
75
76
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
+ ) ;
84
86
}
85
87
}
86
88
} ,
@@ -95,14 +97,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
95
97
let sugg = snippet ( cx, args[ 0 ] . span . source_callsite ( ) , "<expr>" ) . into_owned ( ) ;
96
98
let sugg_msg =
97
99
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
+ ) ;
106
109
}
107
110
}
108
111
}
0 commit comments