From b51a3a565a056235f3864e2cefdb9449f6b0dcb1 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 8 Sep 2025 11:41:43 +0200 Subject: review --- compiler/rustc_next_trait_solver/src/canonicalizer.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_next_trait_solver/src/canonicalizer.rs') diff --git a/compiler/rustc_next_trait_solver/src/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonicalizer.rs index d42c62439f6..a8f2b4e8db6 100644 --- a/compiler/rustc_next_trait_solver/src/canonicalizer.rs +++ b/compiler/rustc_next_trait_solver/src/canonicalizer.rs @@ -67,6 +67,12 @@ pub struct Canonicalizer<'a, D: SolverDelegate, I: Interner> { variables: &'a mut Vec, var_kinds: Vec>, variable_lookup_table: HashMap, + /// Maps each `sub_unification_table_root_var` to the index of the first + /// variable which used it. + /// + /// This means in case two type variables have the same sub relations root, + /// we set the `sub_root` of the second variable to the position of the first. + /// Otherwise the `sub_root` of each type variable is just its own position. sub_root_lookup_table: HashMap, binder_index: ty::DebruijnIndex, @@ -273,7 +279,7 @@ impl<'a, D: SolverDelegate, I: Interner> Canonicalizer<'a, D, I> { } fn get_or_insert_sub_root(&mut self, vid: ty::TyVid) -> ty::BoundVar { - let root_vid = self.delegate.sub_root_ty_var(vid); + let root_vid = self.delegate.sub_unification_table_root_var(vid); let idx = *self.sub_root_lookup_table.entry(root_vid).or_insert_with(|| self.variables.len()); ty::BoundVar::from(idx) -- cgit 1.4.1-3-g733a5