rustc_codegen_llvm::debuginfo::metadata::type_map

Function build_type_with_children

source
pub(super) fn build_type_with_children<'ll, 'tcx>(
    cx: &CodegenCx<'ll, 'tcx>,
    stub_info: StubInfo<'ll, 'tcx>,
    members: impl FnOnce(&CodegenCx<'ll, 'tcx>, &'ll DIType) -> SmallVec<[&'ll DIType; 16]>,
    generics: impl FnOnce(&CodegenCx<'ll, 'tcx>) -> SmallVec<[&'ll DIType; 16]>,
) -> DINodeCreationResult<'ll>
Expand description

This function enables creating debuginfo nodes that can recursively refer to themselves. It will first insert the given stub into the type map and only then execute the members and generics closures passed in. These closures have access to the stub so they can directly attach fields to them. If the type of a field transitively refers back to the type currently being built, the stub will already be found in the type map, which effectively breaks the recursion cycle.