Skip to main content

specialize

Function specialize 

Source
pub fn specialize(
    functions_with_strings: &mut Vec<AnalyzedRow>,
    name_map: &mut FxHashMap<SpecializationKey, Spur>,
    sema: &mut Sema<'_>,
    infer_ctx: &InferenceContext,
    interner: &ThreadedRodeo,
) -> CompileResult<SpecializationRefs>
Expand description

Perform the specialization pass on the analyzed-functions accumulator.

Collects every CallGeneric instruction across the analyzed bodies, rewrites them to direct Calls by mangled name, and synthesizes the specialized bodies. Iterates until the accumulator is closed: each newly-synthesized body can introduce further CallGenerics (transitively-generic specializations), so we re-collect and re-rewrite until no new keys appear.

Returns the set of regular function/method references discovered while analyzing the synthesized bodies. The caller feeds these back into the lazy work queue so reachability stays closed under specialization (e.g. use_greeter[T=Foo] exposes Foo.greet as a reachable method even though main only sees a CallGeneric).