From 66b4e93ba81a49ea5c4f65eba01d9971ab76d2bc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 10 Nov 2025 20:44:23 +0100 Subject: [PATCH] Add instructions on what to do in case casts other than to integers is ever working for function pointers --- compiler/rustc_lint/src/function_cast_as_integer.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_lint/src/function_cast_as_integer.rs b/compiler/rustc_lint/src/function_cast_as_integer.rs index 279e8b8c3ba4..2a4ff1f63db5 100644 --- a/compiler/rustc_lint/src/function_cast_as_integer.rs +++ b/compiler/rustc_lint/src/function_cast_as_integer.rs @@ -39,6 +39,9 @@ impl<'tcx> LateLintPass<'tcx> for FunctionCastsAsInteger { let hir::ExprKind::Cast(cast_from_expr, cast_to_expr) = expr.kind else { return }; let cast_to_ty = cx.typeck_results().expr_ty(expr); // Casting to a function (pointer?), so all good. + // + // Normally, only casts to integers is possible, but if it ever changed, this condition + // will likely need to be updated. if matches!(cast_to_ty.kind(), ty::FnDef(..) | ty::FnPtr(..) | ty::RawPtr(..)) { return; }