about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/infer/combine.rs
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2023-10-23 16:53:11 +0200
committerlcnr <rust@lcnr.de>2023-12-04 10:40:36 +0100
commit407c117e88a036020823e3a7238b141e19edf265 (patch)
tree90744e82e8c102cf9b71784d16023e912f953268 /compiler/rustc_infer/src/infer/combine.rs
parentf69d67221e8333e064620279b46c7c9bcaa88310 (diff)
downloadrust-407c117e88a036020823e3a7238b141e19edf265.tar.gz
rust-407c117e88a036020823e3a7238b141e19edf265.zip
cleanup and comments
Diffstat (limited to 'compiler/rustc_infer/src/infer/combine.rs')
-rw-r--r--compiler/rustc_infer/src/infer/combine.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs
index 862896e0404..759ebaa1d1e 100644
--- a/compiler/rustc_infer/src/infer/combine.rs
+++ b/compiler/rustc_infer/src/infer/combine.rs
@@ -326,7 +326,9 @@ impl<'tcx> InferCtxt<'tcx> {
     ) -> RelateResult<'tcx, ty::Const<'tcx>> {
         let span =
             self.inner.borrow_mut().const_unification_table().probe_value(target_vid).origin.span;
-        let Generalization { value, needs_wf: _ } = generalize::generalize(
+        // FIXME(generic_const_exprs): Occurs check failures for unevaluated
+        // constants and generic expressions are not yet handled correctly.
+        let Generalization { value_may_be_infer: value, needs_wf: _ } = generalize::generalize(
             self,
             &mut CombineDelegate { infcx: self, span, param_env },
             ct,
@@ -334,10 +336,6 @@ impl<'tcx> InferCtxt<'tcx> {
             ty::Variance::Invariant,
         )?;
 
-        // FIXME(generic_const_exprs): Occurs check failures for unevaluated
-        // constants and generic expressions are not yet handled correctly.
-        let value = value.may_be_infer();
-
         self.inner.borrow_mut().const_unification_table().union_value(
             target_vid,
             ConstVarValue {
@@ -449,7 +447,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
         // `'?2` and `?3` are fresh region/type inference
         // variables. (Down below, we will relate `a_ty <: b_ty`,
         // adding constraints like `'x: '?2` and `?1 <: ?3`.)
-        let Generalization { value, needs_wf } = generalize::generalize(
+        let Generalization { value_may_be_infer: b_ty, needs_wf } = generalize::generalize(
             self.infcx,
             &mut CombineDelegate {
                 infcx: self.infcx,
@@ -461,7 +459,6 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
             ambient_variance,
         )?;
 
-        let b_ty = value.may_be_infer(); // we handle this further down.
         self.infcx.inner.borrow_mut().type_variables().instantiate(b_vid, b_ty);
 
         if needs_wf {
@@ -501,6 +498,11 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
                     }
                 }
             }
+
+            // FIXME: This does not handle subtyping correctly, we should switch to
+            // alias-relate in the new solver and could instead create a new inference
+            // variable for `a_ty`, emitting `Projection(a_ty, a_infer)` and
+            // `a_infer <: b_ty`.
             self.obligations.push(Obligation::new(
                 self.tcx(),
                 self.trace.cause.clone(),