@@ -754,13 +754,10 @@ impl_lint_pass!(Casts => [
754754
755755impl < ' tcx > LateLintPass < ' tcx > for Casts {
756756 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 ) {
762758 return ;
763759 }
760+ ptr_as_ptr:: check ( cx, expr, & self . msrv ) ;
764761
765762 if let ExprKind :: Cast ( cast_expr, cast_to_hir) = expr. kind {
766763 if is_hir_ty_cfg_dependant ( cx, cast_to_hir) {
@@ -771,7 +768,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
771768 cx. typeck_results ( ) . expr_ty ( expr) ,
772769 ) ;
773770
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) {
775772 return ;
776773 }
777774 cast_slice_from_raw_parts:: check ( cx, expr, cast_expr, cast_to, & self . msrv ) ;
@@ -782,7 +779,7 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
782779 fn_to_numeric_cast_with_truncation:: check ( cx, expr, cast_expr, cast_from, cast_to) ;
783780 zero_ptr:: check ( cx, expr, cast_expr, cast_to_hir) ;
784781
785- if cast_to. is_numeric ( ) && ! in_external_macro ( cx . sess ( ) , expr . span ) {
782+ if cast_to. is_numeric ( ) {
786783 cast_possible_truncation:: check ( cx, expr, cast_expr, cast_from, cast_to, cast_to_hir. span ) ;
787784 if cast_from. is_numeric ( ) {
788785 cast_possible_wrap:: check ( cx, expr, cast_from, cast_to) ;
0 commit comments