@@ -214,7 +214,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
214
214
e. span ,
215
215
& format ! ( "transmute from a type (`{}`) to a pointer to that type (`{}`)" , from_ty, to_ty) ,
216
216
) ,
217
- ( & ty:: TyRawPtr ( from_pty) , & ty:: TyRef ( _, to_rty ) ) => span_lint_and_then (
217
+ ( & ty:: TyRawPtr ( from_pty) , & ty:: TyRef ( _, to_ref_ty ) ) => span_lint_and_then (
218
218
cx,
219
219
TRANSMUTE_PTR_TO_REF ,
220
220
e. span ,
@@ -226,16 +226,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
226
226
) ,
227
227
|db| {
228
228
let arg = sugg:: Sugg :: hir ( cx, & args[ 0 ] , ".." ) ;
229
- let ( deref, cast) = if to_rty . mutbl == Mutability :: MutMutable {
229
+ let ( deref, cast) = if to_ref_ty . mutbl == Mutability :: MutMutable {
230
230
( "&mut *" , "*mut" )
231
231
} else {
232
232
( "&*" , "*const" )
233
233
} ;
234
234
235
- let arg = if from_pty. ty == to_rty . ty {
235
+ let arg = if from_pty. ty == to_ref_ty . ty {
236
236
arg
237
237
} else {
238
- arg. as_ty ( & format ! ( "{} {}" , cast, get_type_snippet( cx, qpath, to_rty . ty) ) )
238
+ arg. as_ty ( & format ! ( "{} {}" , cast, get_type_snippet( cx, qpath, to_ref_ty . ty) ) )
239
239
} ;
240
240
241
241
db. span_suggestion ( e. span , "try" , sugg:: make_unop ( deref, arg) . to_string ( ) ) ;
@@ -299,17 +299,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Transmute {
299
299
/// the type's `ToString` implementation. In weird cases it could lead to types
300
300
/// with invalid `'_`
301
301
/// lifetime, but it should be rare.
302
- fn get_type_snippet ( cx : & LateContext , path : & QPath , to_rty : Ty ) -> String {
302
+ fn get_type_snippet ( cx : & LateContext , path : & QPath , to_ref_ty : Ty ) -> String {
303
303
let seg = last_path_segment ( path) ;
304
304
if_chain ! {
305
305
if let Some ( ref params) = seg. parameters;
306
306
if !params. parenthesized;
307
307
if let Some ( to_ty) = params. types. get( 1 ) ;
308
308
if let TyRptr ( _, ref to_ty) = to_ty. node;
309
309
then {
310
- return snippet( cx, to_ty. ty. span, & to_rty . to_string( ) ) . to_string( ) ;
310
+ return snippet( cx, to_ty. ty. span, & to_ref_ty . to_string( ) ) . to_string( ) ;
311
311
}
312
312
}
313
313
314
- to_rty . to_string ( )
314
+ to_ref_ty . to_string ( )
315
315
}
0 commit comments