use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation};
use rustc_middle::ty::subst::SubstsRef;
-use rustc_middle::ty::{self, InferConst, ToPredicate, Ty, TyCtxt, TypeVisitable};
+use rustc_middle::ty::{self, InferConst, Ty, TyCtxt, TypeVisitable};
use rustc_middle::ty::{IntType, UintType};
use rustc_span::{Span, DUMMY_SP};
if needs_wf {
self.obligations.push(Obligation::new(
+ self.tcx(),
self.trace.cause.clone(),
self.param_env,
- ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into()))
- .to_predicate(self.infcx.tcx),
+ ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into())),
));
}
ty::PredicateKind::ConstEquate(b, a)
};
self.obligations.push(Obligation::new(
+ self.tcx(),
self.trace.cause.clone(),
self.param_env,
- ty::Binder::dummy(predicate).to_predicate(self.tcx()),
+ ty::Binder::dummy(predicate),
+ ));
+ }
+
+ pub fn mark_ambiguous(&mut self) {
+ self.obligations.push(Obligation::new(
+ self.tcx(),
+ self.trace.cause.clone(),
+ self.param_env,
+ ty::Binder::dummy(ty::PredicateKind::Ambiguous),
));
}
}
fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}
+
+ fn intercrate(&self) -> bool {
+ self.infcx.intercrate
+ }
+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}
true
}
+ fn mark_ambiguous(&mut self) {
+ span_bug!(self.cause.span, "opaque types are handled in `tys`");
+ }
+
fn binders<T>(
&mut self,
a: ty::Binder<'tcx, T>,
&opt_variances,
a_subst,
b_subst,
+ true,
)
}
}
// 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),
}?;
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()))
}
}
}
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),
}
self.infcx.tcx
}
+ fn intercrate(&self) -> bool {
+ assert!(!self.infcx.intercrate);
+ false
+ }
+
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
}
true
}
+ fn mark_ambiguous(&mut self) {
+ bug!()
+ }
+
fn relate_with_variance<T: Relate<'tcx>>(
&mut self,
_variance: ty::Variance,
},
},
);
- Ok(self.tcx().mk_const_var(new_var_id, c.ty()))
+ Ok(self.tcx().mk_const(new_var_id, c.ty()))
}
}
}
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),
}