Bug
ConstCx::fn_sig() in compiler/rustc_const_eval/src/check_consts/mod.rs:66-75 uses is_closure_like() to check if a def_id is a closure, then destructures with let ty::Closure(_, args) = ty.kind(). The is_closure_like() function returns true for all DefKind::Closure, including ty::Coroutine and ty::CoroutineClosure. When one of these types enters the path, the let-else destructure fails and hits bug!("type_of closure not ty::Closure").
Code at fault
// mod.rs:66-75
pub fn fn_sig(&self) -> PolyFnSig<'tcx> {
let did = self.def_id().to_def_id();
if self.tcx.is_closure_like(did) {
let ty = self.tcx.type_of(did).instantiate_identity().skip_norm_wip();
let ty::Closure(_, args) = ty.kind() else { bug!("type_of closure not ty::Closure") };
args.as_closure().sig()
} else {
self.tcx.fn_sig(did).instantiate_identity().skip_norm_wip()
}
}
Status
This method currently has no callers in the compiler (confirmed by grep). The bug is latent: it will ICE when anyone adds a call to ConstCx::fn_sig() for a CoroutineClosure or Coroutine body.
Fix
Add match arms for ty::CoroutineClosure and ty::Coroutine, or narrow the is_closure_like() guard.
Impact
P-high severity (latent ICE) but zero current impact because the method is uncalled. Filing to prevent a future regression when someone adds a caller.
Bug
ConstCx::fn_sig()incompiler/rustc_const_eval/src/check_consts/mod.rs:66-75usesis_closure_like()to check if a def_id is a closure, then destructures withlet ty::Closure(_, args) = ty.kind(). Theis_closure_like()function returns true for allDefKind::Closure, includingty::Coroutineandty::CoroutineClosure. When one of these types enters the path, thelet-elsedestructure fails and hitsbug!("type_of closure not ty::Closure").Code at fault
Status
This method currently has no callers in the compiler (confirmed by grep). The bug is latent: it will ICE when anyone adds a call to
ConstCx::fn_sig()for a CoroutineClosure or Coroutine body.Fix
Add match arms for
ty::CoroutineClosureandty::Coroutine, or narrow theis_closure_like()guard.Impact
P-high severity (latent ICE) but zero current impact because the method is uncalled. Filing to prevent a future regression when someone adds a caller.