Skip to main content

recursive_codec_suffixes

Function recursive_codec_suffixes 

Source
pub fn recursive_codec_suffixes(
    types: &HashMap<String, Arc<TypeDecl>>,
) -> HashSet<String>
Expand description

#2656: the codec suffixes (codec_suffix) whose codecs can call themselves, directly or through other codecs: the named types that take part in a type cycle, and the container and generic-instantiation codecs the cycle passes through (List_Dir for type Dir = { children: List[Dir] }). Only these codecs carry a nesting depth, because only a recursive type can nest without a bound the program text sets. A codec that merely reaches a cycle without being on one (a non-recursive record with a Dir field) is not included: it adds a fixed number of frames.

The graph’s nodes are codec suffixes, its edges the codec calls each codec makes; a node is recursive when it lies on a cycle (a strongly connected component with more than one node, or a self-call). Every non-generic declaration in types is a root, so the answer does not depend on which declarations a module happens to emit. A recursive generic declaration is never expanded: it has no finite codec set and is rejected at the boundary (§6.5).