@@ -338,53 +338,24 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
338
338
let from_ty = cx. typeck_results( ) . expr_ty( & args[ 0 ] ) ;
339
339
let to_ty = cx. typeck_results( ) . expr_ty( e) ;
340
340
341
- let triggered = useless_transmute:: check ( cx , e , from_ty , to_ty , args ) ;
342
- if triggered {
341
+ // If useless_transmute is triggered, the other lints can be skipped.
342
+ if useless_transmute :: check ( cx , e , from_ty , to_ty , args ) {
343
343
return ;
344
344
}
345
- let triggered = wrong_transmute:: check( cx, e, from_ty, to_ty) ;
346
- if triggered {
347
- return ;
348
- }
349
- let triggered = crosspointer_transmute:: check( cx, e, from_ty, to_ty) ;
350
- if triggered {
351
- return ;
352
- }
353
- let triggered = transmute_ptr_to_ref:: check( cx, e, from_ty, to_ty, args, qpath) ;
354
- if triggered {
355
- return ;
356
- }
357
- let triggered = transmute_int_to_char:: check( cx, e, from_ty, to_ty, args) ;
358
- if triggered {
359
- return ;
360
- }
361
- let triggered = transmute_ref_to_ref:: check( cx, e, from_ty, to_ty, args, const_context) ;
362
- if triggered {
363
- return ;
364
- }
365
- let triggered = transmute_ptr_to_ptr:: check( cx, e, from_ty, to_ty, args) ;
366
- if triggered {
367
- return ;
368
- }
369
- let triggered = transmute_int_to_bool:: check( cx, e, from_ty, to_ty, args) ;
370
- if triggered {
371
- return ;
372
- }
373
- let triggered = transmute_int_to_float:: check( cx, e, from_ty, to_ty, args, const_context) ;
374
- if triggered {
375
- return ;
376
- }
377
- let triggered = transmute_float_to_int:: check( cx, e, from_ty, to_ty, args, const_context) ;
378
- if triggered {
379
- return ;
380
- }
381
- let triggered = unsound_collection_transmute:: check( cx, e, from_ty, to_ty) ;
382
- if triggered {
383
- return ;
384
- }
385
- let triggered = transmutes_expressible_as_ptr_casts:: check( cx, e, from_ty, to_ty, args) ;
386
- if triggered {
387
- return ;
345
+
346
+ let mut linted = wrong_transmute:: check( cx, e, from_ty, to_ty) ;
347
+ linted |= crosspointer_transmute:: check( cx, e, from_ty, to_ty) ;
348
+ linted |= transmute_ptr_to_ref:: check( cx, e, from_ty, to_ty, args, qpath) ;
349
+ linted |= transmute_int_to_char:: check( cx, e, from_ty, to_ty, args) ;
350
+ linted |= transmute_ref_to_ref:: check( cx, e, from_ty, to_ty, args, const_context) ;
351
+ linted |= transmute_ptr_to_ptr:: check( cx, e, from_ty, to_ty, args) ;
352
+ linted |= transmute_int_to_bool:: check( cx, e, from_ty, to_ty, args) ;
353
+ linted |= transmute_int_to_float:: check( cx, e, from_ty, to_ty, args, const_context) ;
354
+ linted |= transmute_float_to_int:: check( cx, e, from_ty, to_ty, args, const_context) ;
355
+ linted |= unsound_collection_transmute:: check( cx, e, from_ty, to_ty) ;
356
+
357
+ if !linted {
358
+ transmutes_expressible_as_ptr_casts:: check( cx, e, from_ty, to_ty, args) ;
388
359
}
389
360
}
390
361
}
0 commit comments