From 12b9040cdab9895f7152e09c5401ae446ff12a1e Mon Sep 17 00:00:00 2001 From: lcnr Date: Thu, 22 Feb 2024 12:35:59 +0100 Subject: [PATCH] add comment --- compiler/rustc_middle/src/infer/unify_key.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/infer/unify_key.rs b/compiler/rustc_middle/src/infer/unify_key.rs index 237a465534565..aa9b5ede60579 100644 --- a/compiler/rustc_middle/src/infer/unify_key.rs +++ b/compiler/rustc_middle/src/infer/unify_key.rs @@ -77,7 +77,14 @@ impl<'tcx> UnifyValue for RegionVariableValue<'tcx> { ( RegionVariableValue::Unknown { universe: a }, RegionVariableValue::Unknown { universe: b }, - ) => Ok(RegionVariableValue::Unknown { universe: a.min(b) }), + ) => { + // If we unify two unconstrained regions then whatever + // value they wind up taking (which must be the same value) must + // be nameable by both universes. Therefore, the resulting + // universe is the minimum of the two universes, because that is + // the one which contains the fewest names in scope. + Ok(RegionVariableValue::Unknown { universe: a.min(b) }) + } } } }