about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2021-10-14 16:06:45 +0200
committerGitHub <noreply@github.com>2021-10-14 16:06:45 +0200
commit29081f95e9c7db9abd52eeeb794472a6636c9778 (patch)
treea147a07191e92e84a3bf6de810b3c87b367d0322 /compiler/rustc_trait_selection/src
parentd1777917915f59df0407ddeb16aa9e987481784c (diff)
parent9855e7dc7bdafaafde22d9642eaea43638cf0a8a (diff)
Rollup merge of #89823 - jackh726:project-overflow, r=oli-obk
Switch order of terms to prevent overflow

Fixes #89639

r? ``@pnkfelix``
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/traits/project.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 47b006985ec..db8a6d96204 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -558,7 +558,7 @@ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> {
     fn universe_for(&mut self, debruijn: ty::DebruijnIndex) -> ty::UniverseIndex {
         let infcx = self.infcx;
         let index =
-            self.universe_indices.len() - debruijn.as_usize() + self.current_index.as_usize() - 1;
+            self.universe_indices.len() + self.current_index.as_usize() - debruijn.as_usize() - 1;
         let universe = self.universe_indices[index].unwrap_or_else(|| {
             for i in self.universe_indices.iter_mut().take(index + 1) {
                 *i = i.or_else(|| Some(infcx.create_next_universe()))