fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> CanonicalVar {
        let Canonicalizer {
            variables,
            var_values,
            indices,
            ..
        } = self;

        // This code is hot. `variables` and `var_values` are usually small
        // (fewer than 8 elements ~95% of the time). They are SmallVec's to
        // avoid allocations in those cases. We also don't use `indices` to
        // determine if a kind has been seen before until the limit of 8 has
        // been exceeded, to also avoid allocations for `indices`.
        if var_values.is_array() {
            // `var_values` is stack-allocated. `indices` isn't used yet. Do a
            // direct linear search of `var_values`.
            if let Some(idx) = var_values.iter().position(|&k| k == kind) {
                // `kind` is already present in `var_values`.
                CanonicalVar::new(idx)
            } else {
                // `kind` isn't present in `var_values`. Append it. Likewise
                // for `info` and `variables`.
                variables.push(info);
                var_values.push(kind);
                assert_eq!(variables.len(), var_values.len());

                // If `var_values` has become big enough to be heap-allocated,
                // fill up `indices` to facilitate subsequent lookups.
                if !var_values.is_array() {
                    assert!(indices.is_empty());
                    *indices =
                        var_values.iter()
                            .enumerate()
                            .map(|(i, &kind)| (kind, CanonicalVar::new(i)))
                            .collect();
                }
                // The cv is the index of the appended element.
                CanonicalVar::new(var_values.len() - 1)
            }
        } else {
            // `var_values` is large. Do a hashmap search via `indices`.
            *indices
                .entry(kind)
                .or_insert_with(|| {
                    variables.push(info);
                    var_values.push(kind);
                    assert_eq!(variables.len(), var_values.len());
                    CanonicalVar::new(variables.len() - 1)
                })
        }
    }
/// Creates a canonical variable replacing `kind` from the input,
/// or returns an existing variable if `kind` has already been
/// seen. `kind` is expected to be an unbound variable (or
/// potentially a free region).
Creates a canonical variable replacing `kind` from the input,
or returns an existing variable if `kind` has already been
seen. `kind` is expected to be an unbound variable (or
potentially a free region).
Creates a canonical variable replacing ` kind ` from the input or returns an existing variable if ` kind ` has already been seen . ` kind ` is expected to be an unbound variable ( or potentially a free region ) .
fn canonical_var(&mut self, info: CanonicalVarInfo, kind: Kind<'tcx>) -> CanonicalVar {
        let Canonicalizer {
            variables,
            var_values,
            indices,
            ..
        } = self;
        // This code is hot. `variables` and `var_values` are usually small
        // (fewer than 8 elements ~95% of the time). They are SmallVec's to
        // avoid allocations in those cases. We also don't use `indices` to
        // determine if a kind has been seen before until the limit of 8 has
        // been exceeded, to also avoid allocations for `indices`.
        if var_values.is_array() {
            // `var_values` is stack-allocated. `indices` isn't used yet. Do a
            // direct linear search of `var_values`.
            if let Some(idx) = var_values.iter().position(|&k| k == kind) {
                // `kind` is already present in `var_values`.
                CanonicalVar::new(idx)
            } else {
                // `kind` isn't present in `var_values`. Append it. Likewise
                // for `info` and `variables`.
                variables.push(info);
                var_values.push(kind);
                assert_eq!(variables.len(), var_values.len());
                // If `var_values` has become big enough to be heap-allocated,
                // fill up `indices` to facilitate subsequent lookups.
                if !var_values.is_array() {
                    assert!(indices.is_empty());
                    *indices =
                        var_values.iter()
                            .enumerate()
                            .map(|(i, &kind)| (kind, CanonicalVar::new(i)))
                            .collect();
                }
                // The cv is the index of the appended element.
                CanonicalVar::new(var_values.len() - 1)
            }
        } else {
            // `var_values` is large. Do a hashmap search via `indices`.
            *indices
                .entry(kind)
                .or_insert_with(|| {
                    variables.push(info);
                    var_values.push(kind);
                    assert_eq!(variables.len(), var_values.len());
                    CanonicalVar::new(variables.len() - 1)
                })
        }
    }
fn canonical_var ( & mut self , info : CanonicalVarInfo , kind : Kind < ' tcx > ) -> CanonicalVar { let Canonicalizer { variables , var_values , indices , .. } = self ; // This code is hot. `variables` and `var_values` are usually small // (fewer than 8 elements ~95% of the time). They are SmallVec's to // avoid allocations in those cases. We also don't use `indices` to // determine if a kind has been seen before until the limit of 8 has // been exceeded, to also avoid allocations for `indices`. if var_values . is_array ( ) { // `var_values` is stack-allocated. `indices` isn't used yet. Do a // direct linear search of `var_values`. if let Some ( idx ) = var_values . iter ( ) . position ( | & k | k == kind ) { // `kind` is already present in `var_values`. CanonicalVar :: new ( idx ) } else { // `kind` isn't present in `var_values`. Append it. Likewise // for `info` and `variables`. variables . push ( info ) ; var_values . push ( kind ) ; assert_eq ! ( variables len ( ) var_values len ( ) ) ; // If `var_values` has become big enough to be heap-allocated, // fill up `indices` to facilitate subsequent lookups. if ! var_values . is_array ( ) { assert ! ( indices is_empty ( ) ) ; * indices = var_values . iter ( ) . enumerate ( ) . map ( | ( i , & kind ) | ( kind , CanonicalVar :: new ( i ) ) ) . collect ( ) ; } // The cv is the index of the appended element. CanonicalVar :: new ( var_values . len ( ) - 1 ) } } else { // `var_values` is large. Do a hashmap search via `indices`. * indices . entry ( kind ) . or_insert_with ( | | { variables . push ( info ) ; var_values . push ( kind ) ; assert_eq ! ( variables len ( ) var_values len ( ) ) ; CanonicalVar :: new ( variables . len ( ) - 1 ) } ) } }
Creates a canonical variable replacing `kind` from the input,
or returns an existing variable if `kind` has already been
seen.
Creates a canonical variable replacing ` kind ` from the input or returns an existing variable if ` kind ` has already been seen .
&mut self
info
CanonicalVarInfo
kind
Kind<'tcx>