@@ -9,7 +9,7 @@ use rustc_ast::ast::RangeLimits;
9
9
use rustc_errors:: Applicability ;
10
10
use rustc_hir:: { Expr , ExprKind , Node , Param , PatKind , RangeEnd } ;
11
11
use rustc_lint:: { LateContext , LateLintPass } ;
12
- use rustc_middle:: ty;
12
+ use rustc_middle:: ty:: { self , Ty } ;
13
13
use rustc_session:: impl_lint_pass;
14
14
use rustc_span:: { Span , sym} ;
15
15
@@ -123,15 +123,14 @@ impl<'tcx> LateLintPass<'tcx> for ManualIsAsciiCheck {
123
123
extract_msrv_attr ! ( LateContext ) ;
124
124
}
125
125
126
- fn get_ty_sugg ( cx : & LateContext < ' _ > , arg : & Expr < ' _ > ) -> Option < ( Span , String ) > {
126
+ fn get_ty_sugg < ' tcx > ( cx : & LateContext < ' tcx > , arg : & Expr < ' _ > ) -> Option < ( Span , Ty < ' tcx > ) > {
127
127
let local_hid = path_to_local ( arg) ?;
128
128
if let Node :: Param ( Param { ty_span, span, .. } ) = cx. tcx . parent_hir_node ( local_hid)
129
129
// `ty_span` and `span` are the same for inferred type, thus a type suggestion must be given
130
130
&& ty_span == span
131
131
{
132
132
let arg_type = cx. typeck_results ( ) . expr_ty ( arg) ;
133
- let ty_str = arg_type. to_string ( ) ;
134
- return Some ( ( * ty_span, ty_str) ) ;
133
+ return Some ( ( * ty_span, arg_type) ) ;
135
134
}
136
135
None
137
136
}
@@ -141,7 +140,7 @@ fn check_is_ascii(
141
140
span : Span ,
142
141
recv : & Expr < ' _ > ,
143
142
range : & CharRange ,
144
- ty_sugg : Option < ( Span , String ) > ,
143
+ ty_sugg : Option < ( Span , Ty < ' _ > ) > ,
145
144
) {
146
145
let sugg = match range {
147
146
CharRange :: UpperChar => "is_ascii_uppercase" ,
@@ -155,8 +154,8 @@ fn check_is_ascii(
155
154
let mut app = Applicability :: MachineApplicable ;
156
155
let recv = Sugg :: hir_with_context ( cx, recv, span. ctxt ( ) , default_snip, & mut app) . maybe_par ( ) ;
157
156
let mut suggestion = vec ! [ ( span, format!( "{recv}.{sugg}()" ) ) ] ;
158
- if let Some ( ( ty_span, ty_str ) ) = ty_sugg {
159
- suggestion. push ( ( ty_span, format ! ( "{recv}: {ty_str }" ) ) ) ;
157
+ if let Some ( ( ty_span, ty ) ) = ty_sugg {
158
+ suggestion. push ( ( ty_span, format ! ( "{recv}: {ty }" ) ) ) ;
160
159
}
161
160
162
161
span_lint_and_then (
0 commit comments