rustc_const_eval::check_consts

Function is_safe_to_expose_on_stable_const_fn

Source
pub fn is_safe_to_expose_on_stable_const_fn(
    tcx: TyCtxt<'_>,
    def_id: DefId,
) -> bool
Expand description

Returns true if the given const fn is “safe to expose on stable”.

Panics if the given DefId does not refer to a const fn.

This is relevant within a staged_api crate. Unlike with normal features, the use of unstable const features recursively taints the functions that use them. This is to avoid accidentally exposing e.g. the implementation of an unstable const intrinsic on stable. So we partition the world into two functions: those that are safe to expose on stable (and hence may not use unstable features, not even recursively), and those that are not.