diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /compiler/rustc_hir_analysis/src/variance/solve.rs | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | compiler/rustc_hir_analysis/src/variance/solve.rs | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/compiler/rustc_hir_analysis/src/variance/solve.rs b/compiler/rustc_hir_analysis/src/variance/solve.rs index 97aca621a..a17edb598 100644 --- a/compiler/rustc_hir_analysis/src/variance/solve.rs +++ b/compiler/rustc_hir_analysis/src/variance/solve.rs @@ -5,8 +5,7 @@ //! optimal solution to the constraints. The final variance for each //! inferred is then written into the `variance_map` in the tcx. -use rustc_data_structures::fx::FxHashMap; -use rustc_hir::def_id::DefId; +use rustc_hir::def_id::DefIdMap; use rustc_middle::ty; use super::constraints::*; @@ -28,8 +27,8 @@ pub fn solve_constraints<'tcx>( let ConstraintContext { terms_cx, constraints, .. } = constraints_cx; let mut solutions = vec![ty::Bivariant; terms_cx.inferred_terms.len()]; - for &(id, ref variances) in &terms_cx.lang_items { - let InferredIndex(start) = terms_cx.inferred_starts[&id]; + for (id, variances) in &terms_cx.lang_items { + let InferredIndex(start) = terms_cx.inferred_starts[id]; for (i, &variance) in variances.iter().enumerate() { solutions[start + i] = variance; } @@ -44,7 +43,7 @@ pub fn solve_constraints<'tcx>( impl<'a, 'tcx> SolveContext<'a, 'tcx> { fn solve(&mut self) { - // Propagate constraints until a fixed point is reached. Note + // Propagate constraints until a fixed point is reached. Note // that the maximum number of iterations is 2C where C is the // number of constraints (each variable can change values at most // twice). Since number of constraints is linear in size of the @@ -89,14 +88,12 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { } } - fn create_map(&self) -> FxHashMap<DefId, &'tcx [ty::Variance]> { + fn create_map(&self) -> DefIdMap<&'tcx [ty::Variance]> { let tcx = self.terms_cx.tcx; let solutions = &self.solutions; - self.terms_cx - .inferred_starts - .iter() - .map(|(&def_id, &InferredIndex(start))| { + DefIdMap::from(self.terms_cx.inferred_starts.items().map( + |(&def_id, &InferredIndex(start))| { let generics = tcx.generics_of(def_id); let count = generics.count(); @@ -115,8 +112,8 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { } (def_id.to_def_id(), &*variances) - }) - .collect() + }, + )) } fn evaluate(&self, term: VarianceTermPtr<'a>) -> ty::Variance { |