1
1
use crate :: utils:: {
2
- is_type_diagnostic_item, match_def_path, match_trait_method, paths, same_tys , snippet, snippet_with_macro_callsite,
2
+ is_type_diagnostic_item, match_def_path, match_trait_method, paths, snippet, snippet_with_macro_callsite,
3
3
span_lint_and_help, span_lint_and_sugg,
4
4
} ;
5
5
use if_chain:: if_chain;
6
6
use rustc_errors:: Applicability ;
7
7
use rustc_hir:: { Expr , ExprKind , HirId , MatchSource } ;
8
8
use rustc_lint:: { LateContext , LateLintPass } ;
9
- use rustc_middle:: ty;
9
+ use rustc_middle:: ty:: { self , TyS } ;
10
10
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
11
11
12
12
declare_clippy_lint ! {
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
65
65
if match_trait_method ( cx, e, & paths:: INTO ) && & * name. ident . as_str ( ) == "into" {
66
66
let a = cx. tables . expr_ty ( e) ;
67
67
let b = cx. tables . expr_ty ( & args[ 0 ] ) ;
68
- if same_tys ( cx , a, b) {
68
+ if TyS :: same_type ( a, b) {
69
69
let sugg = snippet_with_macro_callsite ( cx, args[ 0 ] . span , "<expr>" ) . to_string ( ) ;
70
70
span_lint_and_sugg (
71
71
cx,
@@ -81,7 +81,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
81
81
if match_trait_method ( cx, e, & paths:: INTO_ITERATOR ) && & * name. ident . as_str ( ) == "into_iter" {
82
82
let a = cx. tables . expr_ty ( e) ;
83
83
let b = cx. tables . expr_ty ( & args[ 0 ] ) ;
84
- if same_tys ( cx , a, b) {
84
+ if TyS :: same_type ( a, b) {
85
85
let sugg = snippet ( cx, args[ 0 ] . span , "<expr>" ) . into_owned ( ) ;
86
86
span_lint_and_sugg (
87
87
cx,
@@ -101,7 +101,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
101
101
if is_type_diagnostic_item( cx, a, sym!( result_type) ) ;
102
102
if let ty:: Adt ( _, substs) = a. kind;
103
103
if let Some ( a_type) = substs. types( ) . next( ) ;
104
- if same_tys ( cx , a_type, b) ;
104
+ if TyS :: same_type ( a_type, b) ;
105
105
106
106
then {
107
107
span_lint_and_help(
@@ -131,7 +131,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
131
131
if is_type_diagnostic_item( cx, a, sym!( result_type) ) ;
132
132
if let ty:: Adt ( _, substs) = a. kind;
133
133
if let Some ( a_type) = substs. types( ) . next( ) ;
134
- if same_tys ( cx , a_type, b) ;
134
+ if TyS :: same_type ( a_type, b) ;
135
135
136
136
then {
137
137
let hint = format!( "consider removing `{}()`" , snippet( cx, path. span, "TryFrom::try_from" ) ) ;
@@ -148,7 +148,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessConversion {
148
148
149
149
if_chain! {
150
150
if match_def_path( cx, def_id, & paths:: FROM_FROM ) ;
151
- if same_tys ( cx , a, b) ;
151
+ if TyS :: same_type ( a, b) ;
152
152
153
153
then {
154
154
let sugg = snippet( cx, args[ 0 ] . span. source_callsite( ) , "<expr>" ) . into_owned( ) ;
0 commit comments