Skip to main content

rustc_type_ir/
interner.rs

1use std::borrow::Borrow;
2use std::fmt::Debug;
3use std::hash::Hash;
4use std::ops::Deref;
5
6use rustc_ast_ir::Movability;
7use rustc_ast_ir::visit::VisitorResult;
8use rustc_index::bit_set::DenseBitSet;
9
10use crate::fold::TypeFoldable;
11use crate::inherent::*;
12use crate::ir_print::IrPrint;
13use crate::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem};
14use crate::relate::Relate;
15use crate::solve::{
16    AccessedOpaques, CanonicalInput, Certainty, ExternalConstraintsData, QueryResult, inspect,
17};
18use crate::visit::{Flags, TypeVisitable};
19use crate::{self as ty, CanonicalParamEnvCacheEntry, search_graph};
20
21#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "type_ir_interner")]
22pub trait Interner:
23    Sized
24    + Copy
25    + IrPrint<ty::AliasTy<Self>>
26    + IrPrint<ty::AliasTerm<Self>>
27    + IrPrint<ty::TraitRef<Self>>
28    + IrPrint<ty::TraitPredicate<Self>>
29    + IrPrint<ty::HostEffectPredicate<Self>>
30    + IrPrint<ty::ExistentialTraitRef<Self>>
31    + IrPrint<ty::ExistentialProjection<Self>>
32    + IrPrint<ty::ProjectionPredicate<Self>>
33    + IrPrint<ty::NormalizesTo<Self>>
34    + IrPrint<ty::SubtypePredicate<Self>>
35    + IrPrint<ty::CoercePredicate<Self>>
36    + IrPrint<ty::FnSig<Self>>
37    + IrPrint<ty::PatternKind<Self>>
38{
39    fn next_trait_solver_globally(self) -> bool {
40        true
41    }
42
43    type DefId: DefId<Self>;
44    type LocalDefId: Copy + Debug + Hash + Eq + Into<Self::DefId> + TypeFoldable<Self>;
45    // Various more specific `DefId`s.
46    //
47    // rustc just defines them all to be `DefId`, but rust-analyzer uses different types so this is convenient for it.
48    //
49    // Note: The `TryFrom<DefId>` always succeeds (in rustc), so don't use it to check if some `DefId`
50    // is of some specific type!
51    type TraitId: SpecificDefId<Self>;
52    type ForeignId: SpecificDefId<Self>;
53    type FunctionId: SpecificDefId<Self>;
54    type ClosureId: SpecificDefId<Self>;
55    type CoroutineClosureId: SpecificDefId<Self>;
56    type CoroutineId: SpecificDefId<Self>;
57    type AdtId: SpecificDefId<Self>;
58    type ImplId: SpecificDefId<Self>;
59    type UnevaluatedConstId: SpecificDefId<Self>;
60    type TraitAssocTyId: SpecificDefId<Self>
61        + Into<Self::TraitAssocTermId>
62        + TryFrom<Self::TraitAssocTermId>;
63    type TraitAssocConstId: SpecificDefId<Self>
64        + Into<Self::TraitAssocTermId>
65        + Into<Self::UnevaluatedConstId>
66        + TryFrom<Self::TraitAssocTermId>;
67    type TraitAssocTermId: SpecificDefId<Self>;
68    type OpaqueTyId: SpecificDefId<Self, Self::LocalOpaqueTyId>;
69    type LocalOpaqueTyId: Copy
70        + Debug
71        + Hash
72        + Eq
73        + Into<Self::OpaqueTyId>
74        + Into<Self::LocalDefId>
75        + Into<Self::DefId>
76        + TypeFoldable<Self>;
77    type FreeTyAliasId: SpecificDefId<Self> + Into<Self::FreeTermAliasId>;
78    type FreeConstAliasId: SpecificDefId<Self>
79        + Into<Self::UnevaluatedConstId>
80        + Into<Self::FreeTermAliasId>;
81    type FreeTermAliasId: SpecificDefId<Self>;
82    type ImplOrTraitAssocTyId: SpecificDefId<Self> + Into<Self::ImplOrTraitAssocTermId>;
83    type ImplOrTraitAssocConstId: SpecificDefId<Self>
84        + Into<Self::UnevaluatedConstId>
85        + Into<Self::ImplOrTraitAssocTermId>;
86    type ImplOrTraitAssocTermId: SpecificDefId<Self>;
87    type InherentAssocTyId: SpecificDefId<Self> + Into<Self::InherentAssocTermId>;
88    type InherentAssocConstId: SpecificDefId<Self>
89        + Into<Self::UnevaluatedConstId>
90        + Into<Self::InherentAssocTermId>;
91    type InherentAssocTermId: SpecificDefId<Self>;
92    type Span: Span<Self>;
93
94    type GenericArgs: GenericArgs<Self>;
95    type GenericArgsSlice: Copy + Debug + Hash + Eq + SliceLike<Item = Self::GenericArg>;
96    type GenericArg: GenericArg<Self>;
97    type Term: Term<Self>;
98
99    type BoundVarKinds: BoundVarKinds<Self>;
100
101    type PredefinedOpaques: Copy
102        + Debug
103        + Hash
104        + Eq
105        + TypeFoldable<Self>
106        + SliceLike<Item = (ty::OpaqueTypeKey<Self>, Self::Ty)>;
107    fn mk_predefined_opaques_in_body(
108        self,
109        data: &[(ty::OpaqueTypeKey<Self>, Self::Ty)],
110    ) -> Self::PredefinedOpaques;
111
112    type LocalDefIds: Copy
113        + Debug
114        + Hash
115        + Default
116        + Eq
117        + TypeVisitable<Self>
118        + SliceLike<Item = Self::LocalDefId>;
119
120    type CanonicalVarKinds: Copy
121        + Debug
122        + Hash
123        + Eq
124        + SliceLike<Item = ty::CanonicalVarKind<Self>>
125        + Default;
126    fn mk_canonical_var_kinds(
127        self,
128        kinds: &[ty::CanonicalVarKind<Self>],
129    ) -> Self::CanonicalVarKinds;
130
131    type ExternalConstraints: Copy
132        + Debug
133        + Hash
134        + Eq
135        + TypeFoldable<Self>
136        + Deref<Target = ExternalConstraintsData<Self>>;
137    fn mk_external_constraints(
138        self,
139        data: ExternalConstraintsData<Self>,
140    ) -> Self::ExternalConstraints;
141
142    type DepNodeIndex;
143    type Tracked<T: Debug + Clone>: Debug;
144    fn mk_tracked<T: Debug + Clone>(
145        self,
146        data: T,
147        dep_node: Self::DepNodeIndex,
148    ) -> Self::Tracked<T>;
149    fn get_tracked<T: Debug + Clone>(self, tracked: &Self::Tracked<T>) -> T;
150    fn with_cached_task<T>(self, task: impl FnOnce() -> T) -> (T, Self::DepNodeIndex);
151
152    // Kinds of tys
153    type Ty: Ty<Self>;
154    type Tys: Tys<Self>;
155    type FnInputTys: Copy + Debug + Hash + Eq + SliceLike<Item = Self::Ty> + TypeVisitable<Self>;
156    type ParamTy: ParamLike;
157    type Symbol: Symbol<Self>;
158
159    // Things stored inside of tys
160    type ErrorGuaranteed: Copy + Debug + Hash + Eq;
161    type BoundExistentialPredicates: BoundExistentialPredicates<Self>;
162    type AllocId: Copy + Debug + Hash + Eq;
163    type Pat: Copy
164        + Debug
165        + Hash
166        + Eq
167        + Debug
168        + Relate<Self>
169        + Flags
170        + IntoKind<Kind = ty::PatternKind<Self>>;
171    type PatList: Copy
172        + Debug
173        + Hash
174        + Default
175        + Eq
176        + TypeVisitable<Self>
177        + SliceLike<Item = Self::Pat>;
178    type Safety: Safety<Self>;
179
180    // Kinds of consts
181    type Const: Const<Self>;
182    type Consts: Copy + Debug + Hash + Eq + SliceLike<Item = Self::Const> + Default;
183    type ParamConst: Copy + Debug + Hash + Eq + ParamLike;
184    type ValueConst: ValueConst<Self>;
185    type ExprConst: ExprConst<Self>;
186    type ValTree: Copy + Debug + Hash + Eq + IntoKind<Kind = ty::ValTreeKind<Self>>;
187    type ScalarInt: Copy + Debug + Hash + Eq;
188
189    // Kinds of regions
190    type Region: Region<Self>;
191    type EarlyParamRegion: ParamLike;
192    type LateParamRegion: Copy + Debug + Hash + Eq;
193
194    type RegionAssumptions: Copy
195        + Debug
196        + Hash
197        + Eq
198        + SliceLike<Item = ty::OutlivesPredicate<Self, Self::GenericArg>>
199        + TypeFoldable<Self>;
200
201    // Predicates
202    type ParamEnv: ParamEnv<Self>;
203    type Predicate: Predicate<Self>;
204    type Clause: Clause<Self>;
205    type Clauses: Clauses<Self>;
206
207    fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R) -> R;
208
209    fn canonical_param_env_cache_get_or_insert<R>(
210        self,
211        param_env: Self::ParamEnv,
212        f: impl FnOnce() -> CanonicalParamEnvCacheEntry<Self>,
213        from_entry: impl FnOnce(&CanonicalParamEnvCacheEntry<Self>) -> R,
214    ) -> R;
215
216    /// Useful for testing. If a cache entry is replaced, this should
217    /// (in theory) only happen when concurrent.
218    fn assert_evaluation_is_concurrent(&self);
219
220    fn expand_abstract_consts<T: TypeFoldable<Self>>(self, t: T) -> T;
221
222    type GenericsOf: GenericsOf<Self>;
223    fn generics_of(self, def_id: Self::DefId) -> Self::GenericsOf;
224
225    type VariancesOf: Copy + Debug + SliceLike<Item = ty::Variance>;
226    fn variances_of(self, def_id: Self::DefId) -> Self::VariancesOf;
227
228    fn opt_alias_variances(
229        self,
230        kind: impl Into<ty::AliasTermKind<Self>>,
231    ) -> Option<Self::VariancesOf>;
232
233    fn type_of(self, def_id: Self::DefId) -> ty::EarlyBinder<Self, Self::Ty>;
234    fn type_of_opaque_hir_typeck(
235        self,
236        def_id: Self::LocalOpaqueTyId,
237    ) -> ty::EarlyBinder<Self, Self::Ty>;
238    fn is_type_const(self, def_id: Self::DefId) -> bool;
239    fn const_of_item(self, def_id: Self::DefId) -> ty::EarlyBinder<Self, Self::Const>;
240    fn anon_const_kind(self, def_id: Self::DefId) -> ty::AnonConstKind;
241
242    type AdtDef: AdtDef<Self>;
243    fn adt_def(self, adt_def_id: Self::AdtId) -> Self::AdtDef;
244
245    fn alias_ty_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasTyKind<Self>;
246
247    // FIXME: remove in favor of explicit construction
248    fn alias_term_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasTermKind<Self>;
249
250    fn trait_ref_and_own_args_for_alias(
251        self,
252        def_id: Self::TraitAssocTermId,
253        args: Self::GenericArgs,
254    ) -> (ty::TraitRef<Self>, Self::GenericArgsSlice);
255
256    fn mk_args(self, args: &[Self::GenericArg]) -> Self::GenericArgs;
257
258    fn mk_args_from_iter<I, T>(self, args: I) -> T::Output
259    where
260        I: Iterator<Item = T>,
261        T: CollectAndApply<Self::GenericArg, Self::GenericArgs>;
262
263    fn check_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs) -> bool;
264
265    fn debug_assert_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs);
266
267    /// Assert that the args from an `ExistentialTraitRef` or `ExistentialProjection`
268    /// are compatible with the `DefId`.
269    fn debug_assert_existential_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs);
270
271    fn mk_type_list_from_iter<I, T>(self, args: I) -> T::Output
272    where
273        I: Iterator<Item = T>,
274        T: CollectAndApply<Self::Ty, Self::Tys>;
275
276    fn projection_parent(self, def_id: Self::TraitAssocTermId) -> Self::TraitId;
277
278    /// This can be an impl, or a trait if this is a defaulted term.
279    fn impl_or_trait_assoc_term_parent(self, def_id: Self::ImplOrTraitAssocTermId) -> Self::DefId;
280
281    fn inherent_alias_term_parent(self, def_id: Self::InherentAssocTermId) -> Self::ImplId;
282
283    fn recursion_limit(self) -> usize;
284
285    type Features: Features<Self>;
286    fn features(self) -> Self::Features;
287
288    fn assumptions_on_binders(self) -> bool;
289
290    fn coroutine_hidden_types(
291        self,
292        def_id: Self::CoroutineId,
293    ) -> ty::EarlyBinder<Self, ty::Binder<Self, ty::CoroutineWitnessTypes<Self>>>;
294
295    fn fn_sig(
296        self,
297        def_id: Self::FunctionId,
298    ) -> ty::EarlyBinder<Self, ty::Binder<Self, ty::FnSig<Self>>>;
299
300    fn coroutine_movability(self, def_id: Self::CoroutineId) -> Movability;
301
302    fn coroutine_for_closure(self, def_id: Self::CoroutineClosureId) -> Self::CoroutineId;
303
304    fn generics_require_sized_self(self, def_id: Self::DefId) -> bool;
305
306    fn item_bounds(
307        self,
308        def_id: Self::DefId,
309    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
310
311    fn item_self_bounds(
312        self,
313        def_id: Self::DefId,
314    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
315
316    fn item_non_self_bounds(
317        self,
318        def_id: Self::DefId,
319    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
320
321    fn predicates_of(
322        self,
323        def_id: Self::DefId,
324    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
325
326    fn own_predicates_of(
327        self,
328        def_id: Self::DefId,
329    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
330
331    fn explicit_super_predicates_of(
332        self,
333        def_id: Self::TraitId,
334    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = (Self::Clause, Self::Span)>>;
335
336    fn explicit_implied_predicates_of(
337        self,
338        def_id: Self::DefId,
339    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = (Self::Clause, Self::Span)>>;
340
341    /// This is equivalent to computing the super-predicates of the trait for this impl
342    /// and filtering them to the outlives predicates. This is purely for performance.
343    fn impl_super_outlives(
344        self,
345        impl_def_id: Self::ImplId,
346    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;
347
348    fn impl_is_const(self, def_id: Self::ImplId) -> bool;
349    fn fn_is_const(self, def_id: Self::FunctionId) -> bool;
350    fn closure_is_const(self, def_id: Self::ClosureId) -> bool;
351    fn alias_has_const_conditions(self, def_id: Self::DefId) -> bool;
352    fn const_conditions(
353        self,
354        def_id: Self::DefId,
355    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = ty::Binder<Self, ty::TraitRef<Self>>>>;
356    fn explicit_implied_const_bounds(
357        self,
358        def_id: Self::DefId,
359    ) -> ty::EarlyBinder<Self, impl IntoIterator<Item = ty::Binder<Self, ty::TraitRef<Self>>>>;
360
361    fn impl_self_is_guaranteed_unsized(self, def_id: Self::ImplId) -> bool;
362
363    fn has_target_features(self, def_id: Self::FunctionId) -> bool;
364
365    fn require_projection_lang_item(
366        self,
367        lang_item: SolverProjectionLangItem,
368    ) -> Self::TraitAssocTyId;
369
370    fn require_trait_lang_item(self, lang_item: SolverTraitLangItem) -> Self::TraitId;
371
372    fn require_adt_lang_item(self, lang_item: SolverAdtLangItem) -> Self::AdtId;
373
374    fn is_projection_lang_item(
375        self,
376        def_id: Self::TraitAssocTyId,
377        lang_item: SolverProjectionLangItem,
378    ) -> bool;
379
380    fn is_trait_lang_item(self, def_id: Self::TraitId, lang_item: SolverTraitLangItem) -> bool;
381
382    fn is_adt_lang_item(self, def_id: Self::AdtId, lang_item: SolverAdtLangItem) -> bool;
383
384    fn is_default_trait(self, def_id: Self::TraitId) -> bool;
385
386    fn is_sizedness_trait(self, def_id: Self::TraitId) -> bool;
387
388    fn as_projection_lang_item(
389        self,
390        def_id: Self::TraitAssocTyId,
391    ) -> Option<SolverProjectionLangItem>;
392
393    fn as_trait_lang_item(self, def_id: Self::TraitId) -> Option<SolverTraitLangItem>;
394
395    fn as_adt_lang_item(self, def_id: Self::AdtId) -> Option<SolverAdtLangItem>;
396
397    fn associated_type_def_ids(
398        self,
399        def_id: Self::TraitId,
400    ) -> impl IntoIterator<Item = Self::DefId>;
401
402    fn for_each_relevant_impl<R: VisitorResult>(
403        self,
404        trait_def_id: Self::TraitId,
405        self_ty: Self::Ty,
406        f: impl FnMut(Self::ImplId) -> R,
407    ) -> R;
408    fn for_each_blanket_impl<R: VisitorResult>(
409        self,
410        trait_def_id: Self::TraitId,
411        f: impl FnMut(Self::ImplId) -> R,
412    ) -> R;
413
414    fn has_item_definition(self, def_id: Self::ImplOrTraitAssocTermId) -> bool;
415
416    fn impl_specializes(self, impl_def_id: Self::ImplId, victim_def_id: Self::ImplId) -> bool;
417
418    fn impl_is_default(self, impl_def_id: Self::ImplId) -> bool;
419
420    fn impl_trait_ref(self, impl_def_id: Self::ImplId)
421    -> ty::EarlyBinder<Self, ty::TraitRef<Self>>;
422
423    fn impl_polarity(self, impl_def_id: Self::ImplId) -> ty::ImplPolarity;
424
425    fn trait_is_auto(self, trait_def_id: Self::TraitId) -> bool;
426
427    fn trait_is_coinductive(self, trait_def_id: Self::TraitId) -> bool;
428
429    fn trait_is_alias(self, trait_def_id: Self::TraitId) -> bool;
430
431    fn trait_is_dyn_compatible(self, trait_def_id: Self::TraitId) -> bool;
432
433    fn trait_is_fundamental(self, def_id: Self::TraitId) -> bool;
434
435    /// Returns `true` if this is an `unsafe trait`.
436    fn trait_is_unsafe(self, trait_def_id: Self::TraitId) -> bool;
437
438    fn is_impl_trait_in_trait(self, def_id: Self::DefId) -> bool;
439
440    fn delay_bug(self, msg: impl ToString) -> Self::ErrorGuaranteed;
441
442    fn is_general_coroutine(self, coroutine_def_id: Self::CoroutineId) -> bool;
443    fn coroutine_is_async(self, coroutine_def_id: Self::CoroutineId) -> bool;
444    fn coroutine_is_gen(self, coroutine_def_id: Self::CoroutineId) -> bool;
445    fn coroutine_is_async_gen(self, coroutine_def_id: Self::CoroutineId) -> bool;
446
447    type UnsizingParams: Deref<Target = DenseBitSet<u32>>;
448    fn unsizing_params_for_adt(self, adt_def_id: Self::AdtId) -> Self::UnsizingParams;
449
450    fn anonymize_bound_vars<T: TypeFoldable<Self>>(
451        self,
452        binder: ty::Binder<Self, T>,
453    ) -> ty::Binder<Self, T>;
454
455    fn opaque_types_defined_by(self, defining_anchor: Self::LocalDefId) -> Self::LocalDefIds;
456
457    fn opaque_types_and_coroutines_defined_by(
458        self,
459        defining_anchor: Self::LocalDefId,
460    ) -> Self::LocalDefIds;
461
462    type Probe: Debug + Hash + Eq + Borrow<inspect::Probe<Self>>;
463    fn mk_probe(self, probe: inspect::Probe<Self>) -> Self::Probe;
464    fn evaluate_root_goal_for_proof_tree_raw(
465        self,
466        canonical_goal: CanonicalInput<Self>,
467    ) -> (QueryResult<Self>, Self::Probe);
468
469    fn item_name(self, item_index: Self::DefId) -> Self::Symbol;
470}
471
472/// Imagine you have a function `F: FnOnce(&[T]) -> R`, plus an iterator `iter`
473/// that produces `T` items. You could combine them with
474/// `f(&iter.collect::<Vec<_>>())`, but this requires allocating memory for the
475/// `Vec`.
476///
477/// This trait allows for faster implementations, intended for cases where the
478/// number of items produced by the iterator is small. There is a blanket impl
479/// for `T` items, but there is also a fallible impl for `Result<T, E>` items.
480pub trait CollectAndApply<T, R>: Sized {
481    type Output;
482
483    /// Produce a result of type `Self::Output` from `iter`. The result will
484    /// typically be produced by applying `f` on the elements produced by
485    /// `iter`, though this may not happen in some impls, e.g. if an error
486    /// occurred during iteration.
487    fn collect_and_apply<I, F>(iter: I, f: F) -> Self::Output
488    where
489        I: Iterator<Item = Self>,
490        F: FnOnce(&[T]) -> R;
491}
492
493/// The blanket impl that always collects all elements and applies `f`.
494impl<T, R> CollectAndApply<T, R> for T {
495    type Output = R;
496
497    /// Equivalent to `f(&iter.collect::<Vec<_>>())`.
498    fn collect_and_apply<I, F>(mut iter: I, f: F) -> R
499    where
500        I: Iterator<Item = T>,
501        F: FnOnce(&[T]) -> R,
502    {
503        // This code is hot enough that it's worth specializing for the most
504        // common length lists, to avoid the overhead of `Vec` creation.
505
506        let Some(t0) = iter.next() else {
507            return f(&[]);
508        };
509
510        let Some(t1) = iter.next() else {
511            return f(&[t0]);
512        };
513
514        let Some(t2) = iter.next() else {
515            return f(&[t0, t1]);
516        };
517
518        let Some(t3) = iter.next() else {
519            return f(&[t0, t1, t2]);
520        };
521
522        let Some(t4) = iter.next() else {
523            return f(&[t0, t1, t2, t3]);
524        };
525
526        let Some(t5) = iter.next() else {
527            return f(&[t0, t1, t2, t3, t4]);
528        };
529
530        let Some(t6) = iter.next() else {
531            return f(&[t0, t1, t2, t3, t4, t5]);
532        };
533
534        let Some(t7) = iter.next() else {
535            return f(&[t0, t1, t2, t3, t4, t5, t6]);
536        };
537
538        let Some(t8) = iter.next() else {
539            return f(&[t0, t1, t2, t3, t4, t5, t6, t7]);
540        };
541
542        f(&[t0, t1, t2, t3, t4, t5, t6, t7, t8].into_iter().chain(iter).collect::<Vec<_>>())
543    }
544}
545
546/// A fallible impl that will fail, without calling `f`, if there are any
547/// errors during collection.
548impl<T, R, E> CollectAndApply<T, R> for Result<T, E> {
549    type Output = Result<R, E>;
550
551    /// Equivalent to `Ok(f(&iter.collect::<Result<Vec<_>>>()?))`.
552    fn collect_and_apply<I, F>(mut iter: I, f: F) -> Result<R, E>
553    where
554        I: Iterator<Item = Result<T, E>>,
555        F: FnOnce(&[T]) -> R,
556    {
557        // This code is hot enough that it's worth specializing for the most
558        // common length lists, to avoid the overhead of `Vec` creation.
559
560        let Some(t0) = iter.next() else {
561            return Ok(f(&[]));
562        };
563        let t0 = t0?;
564
565        let Some(t1) = iter.next() else {
566            return Ok(f(&[t0]));
567        };
568        let t1 = t1?;
569
570        let Some(t2) = iter.next() else {
571            return Ok(f(&[t0, t1]));
572        };
573        let t2 = t2?;
574
575        let Some(t3) = iter.next() else {
576            return Ok(f(&[t0, t1, t2]));
577        };
578        let t3 = t3?;
579
580        let Some(t4) = iter.next() else {
581            return Ok(f(&[t0, t1, t2, t3]));
582        };
583        let t4 = t4?;
584
585        let Some(t5) = iter.next() else {
586            return Ok(f(&[t0, t1, t2, t3, t4]));
587        };
588        let t5 = t5?;
589
590        let Some(t6) = iter.next() else {
591            return Ok(f(&[t0, t1, t2, t3, t4, t5]));
592        };
593        let t6 = t6?;
594
595        let Some(t7) = iter.next() else {
596            return Ok(f(&[t0, t1, t2, t3, t4, t5, t6]));
597        };
598        let t7 = t7?;
599
600        let Some(t8) = iter.next() else {
601            return Ok(f(&[t0, t1, t2, t3, t4, t5, t6, t7]));
602        };
603        let t8 = t8?;
604
605        Ok(f(&[Ok(t0), Ok(t1), Ok(t2), Ok(t3), Ok(t4), Ok(t5), Ok(t6), Ok(t7), Ok(t8)]
606            .into_iter()
607            .chain(iter)
608            .collect::<Result<Vec<_>, _>>()?))
609    }
610}
611
612impl<I: Interner> search_graph::Cx for I {
613    type Input = CanonicalInput<I>;
614    type Result = (QueryResult<I>, AccessedOpaques<I>);
615    type AmbiguityInfo = Certainty;
616
617    type DepNodeIndex = I::DepNodeIndex;
618    type Tracked<T: Debug + Clone> = I::Tracked<T>;
619    fn mk_tracked<T: Debug + Clone>(
620        self,
621        data: T,
622        dep_node_index: I::DepNodeIndex,
623    ) -> I::Tracked<T> {
624        I::mk_tracked(self, data, dep_node_index)
625    }
626    fn get_tracked<T: Debug + Clone>(self, tracked: &I::Tracked<T>) -> T {
627        I::get_tracked(self, tracked)
628    }
629    fn with_cached_task<T>(self, task: impl FnOnce() -> T) -> (T, I::DepNodeIndex) {
630        I::with_cached_task(self, task)
631    }
632    fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R) -> R {
633        I::with_global_cache(self, f)
634    }
635    fn assert_evaluation_is_concurrent(&self) {
636        self.assert_evaluation_is_concurrent()
637    }
638}