@@ -754,13 +754,10 @@ impl_lint_pass!(Casts => [
754
754
755
755
impl < ' tcx > LateLintPass < ' tcx > for Casts {
756
756
fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > ) {
757
- if !in_external_macro ( cx. sess ( ) , expr. span ) {
758
- ptr_as_ptr:: check ( cx, expr, & self . msrv ) ;
759
- }
760
-
761
- if expr. span . from_expansion ( ) {
757
+ if in_external_macro ( cx. sess ( ) , expr. span ) {
762
758
return ;
763
759
}
760
+ ptr_as_ptr:: check ( cx, expr, & self . msrv ) ;
764
761
765
762
if let ExprKind :: Cast ( cast_expr, cast_to_hir) = expr. kind {
766
763
if is_hir_ty_cfg_dependant ( cx, cast_to_hir) {
@@ -771,7 +768,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
771
768
cx. typeck_results ( ) . expr_ty ( expr) ,
772
769
) ;
773
770
774
- if unnecessary_cast:: check ( cx, expr, cast_expr, cast_from, cast_to) {
771
+ if !expr . span . from_expansion ( ) && unnecessary_cast:: check ( cx, expr, cast_expr, cast_from, cast_to) {
775
772
return ;
776
773
}
777
774
cast_slice_from_raw_parts:: check ( cx, expr, cast_expr, cast_to, & self . msrv ) ;
@@ -782,7 +779,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
782
779
fn_to_numeric_cast_with_truncation:: check ( cx, expr, cast_expr, cast_from, cast_to) ;
783
780
zero_ptr:: check ( cx, expr, cast_expr, cast_to_hir) ;
784
781
785
- if cast_to. is_numeric ( ) && ! in_external_macro ( cx . sess ( ) , expr . span ) {
782
+ if cast_to. is_numeric ( ) {
786
783
cast_possible_truncation:: check ( cx, expr, cast_expr, cast_from, cast_to, cast_to_hir. span ) ;
787
784
if cast_from. is_numeric ( ) {
788
785
cast_possible_wrap:: check ( cx, expr, cast_from, cast_to) ;
0 commit comments