flâneur — a map of the web's best reading

Variance - Rust Compiler Development Guide

rustc-dev-guide.rust-lang.org · 2,044 words · saved by 1 readers

During type checking we must infer the variance of type and lifetime parameters. The algorithm is taken from Section 4 of the paper "Taming the Wildcards: Combining Definition- and Use-Site Variance" published in PLDI'11 and written by Altidor et al., and hereafter referred to as The Paper. This inference is explicitly designed not to consider the uses of types within code. To determine the variance of type parameters defined on type X, we only consider the definition of the type X and the definitions of any types it references. We only infer variance for type parameters found on data types like structs and enums. In these cases, there is a fairly straightforward explanation for what variance means. The variance of the type or lifetime parameters defines whether T<A> is a subtype of T<B> (resp. T<'a> and T<'b>) based on the relationship of A and B (resp. 'a and 'b). We do not infer variance for type parameters found on traits, functions, or impls. Variance on trait parameters can indee

Variance - Rust Compiler Development Guide Keyboard shortcuts Press ← or → to navigate between chapters Press S or / to search in the book Press ? to show this help Press Esc to hide this help Auto Light Rust Coal Navy Ayu Rust Compiler Development Guide Variance of type and lifetime parameters For a more general background on variance, see the background appendix. During type checking we must infer the variance of type and lifetime parameters. The algorithm is taken from Section 4 of the paper “Taming the Wildcards: Combining Definition- and Use-Site Variance” published in PLDI’11 and written

Explore this link on the map →

saved by

related reading