Add instructions on what to do in case casts other than to integers is ever working for function pointers

This commit is contained in:
Guillaume Gomez 2025-11-10 20:44:23 +01:00
parent d05f297164
commit 66b4e93ba8

View file

@ -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;
}