]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_infer/src/infer/combine.rs
Auto merge of #105094 - Swatinem:generator-not-future, r=compiler-errors
[rust.git] / compiler / rustc_infer / src / infer / combine.rs
index 53a19f8e4ec55aa38d58bf2635df9162fec68072..cf895ed0d3e598ba23eb5effcb52345e75982045 100644 (file)
@@ -548,8 +548,7 @@ fn a_is_expected(&self) -> bool {
     }
 
     fn mark_ambiguous(&mut self) {
-        // The generalizer always compares types against themselves,
-        // and thus doesn't really take part in coherence.
+        span_bug!(self.cause.span, "opaque types are handled in `tys`");
     }
 
     fn binders<T>(
@@ -676,6 +675,10 @@ fn tys(&mut self, t: Ty<'tcx>, t2: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
                 // relatable.
                 Ok(t)
             }
+            ty::Opaque(def_id, substs) => {
+                let s = self.relate(substs, substs)?;
+                Ok(if s == substs { t } else { self.infcx.tcx.mk_opaque(def_id, s) })
+            }
             _ => relate::super_relate_tys(self, t, t),
         }?;
 
@@ -750,7 +753,7 @@ fn consts(
                                 origin: var_value.origin,
                                 val: ConstVariableValue::Unknown { universe: self.for_universe },
                             });
-                            Ok(self.tcx().mk_const_var(new_var_id, c.ty()))
+                            Ok(self.tcx().mk_const(new_var_id, c.ty()))
                         }
                     }
                 }
@@ -762,10 +765,7 @@ fn consts(
                     substs,
                     substs,
                 )?;
-                Ok(self.tcx().mk_const(
-                    ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
-                    c.ty(),
-                ))
+                Ok(self.tcx().mk_const(ty::UnevaluatedConst { def, substs }, c.ty()))
             }
             _ => relate::super_relate_consts(self, c, c),
         }
@@ -819,7 +819,8 @@ fn tcx(&self) -> TyCtxt<'tcx> {
     }
 
     fn intercrate(&self) -> bool {
-        self.infcx.intercrate
+        assert!(!self.infcx.intercrate);
+        false
     }
 
     fn param_env(&self) -> ty::ParamEnv<'tcx> {
@@ -971,7 +972,7 @@ fn consts(
                                         },
                                     },
                                 );
-                            Ok(self.tcx().mk_const_var(new_var_id, c.ty()))
+                            Ok(self.tcx().mk_const(new_var_id, c.ty()))
                         }
                     }
                 }
@@ -984,10 +985,7 @@ fn consts(
                     substs,
                 )?;
 
-                Ok(self.tcx().mk_const(
-                    ty::ConstKind::Unevaluated(ty::UnevaluatedConst { def, substs }),
-                    c.ty(),
-                ))
+                Ok(self.tcx().mk_const(ty::UnevaluatedConst { def, substs }, c.ty()))
             }
             _ => relate::super_relate_consts(self, c, c),
         }