diff options
| author | lcnr <rust@lcnr.de> | 2025-09-08 11:41:43 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2025-09-08 14:17:56 +0200 |
| commit | b51a3a565a056235f3864e2cefdb9449f6b0dcb1 (patch) | |
| tree | 525669b67e94ecdfe97995123eb4f79886831f2d /compiler/rustc_next_trait_solver/src/canonicalizer.rs | |
| parent | f51458640840cb94c32f1e55431b1c855ca22e88 (diff) | |
| download | rust-b51a3a565a056235f3864e2cefdb9449f6b0dcb1.tar.gz rust-b51a3a565a056235f3864e2cefdb9449f6b0dcb1.zip | |
review
Diffstat (limited to 'compiler/rustc_next_trait_solver/src/canonicalizer.rs')
| -rw-r--r-- | compiler/rustc_next_trait_solver/src/canonicalizer.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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<Interner = I>, I: Interner> { variables: &'a mut Vec<I::GenericArg>, var_kinds: Vec<CanonicalVarKind<I>>, variable_lookup_table: HashMap<I::GenericArg, usize>, + /// 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<ty::TyVid, usize>, binder_index: ty::DebruijnIndex, @@ -273,7 +279,7 @@ impl<'a, D: SolverDelegate<Interner = I>, 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) |
