.into()
}
GenericArgKind::Const(ct) => {
- match ct.val() {
+ match ct.kind() {
ty::ConstKind::Infer(infer) => {
let resolved = infcx.shallow_resolve(infer);
if resolved == infer {
infcx
.tcx
- .mk_const(ty::ConstS { val: ty::ConstKind::Infer(resolved), ty: ct.ty() })
+ .mk_const(ty::ConstS { kind: ty::ConstKind::Infer(resolved), ty: ct.ty() })
}
_ => ct,
}
body_id: hir::HirId,
trait_ref: &ty::TraitRef<'tcx>,
span: Span,
- item: Option<&'tcx hir::Item<'tcx>>,
+ item: &'tcx hir::Item<'tcx>,
) -> Vec<traits::PredicateObligation<'tcx>> {
- let mut wf =
- WfPredicates { infcx, param_env, body_id, span, out: vec![], recursion_depth: 0, item };
+ let mut wf = WfPredicates {
+ infcx,
+ param_env,
+ body_id,
+ span,
+ out: vec![],
+ recursion_depth: 0,
+ item: Some(item),
+ };
wf.compute_trait_ref(trait_ref, Elaborate::All);
debug!(obligations = ?wf.out);
wf.normalize()
let obligations = self.nominal_obligations(trait_ref.def_id, trait_ref.substs);
debug!("compute_trait_ref obligations {:?}", obligations);
- let cause = self.cause(traits::MiscObligation);
let param_env = self.param_env;
let depth = self.recursion_depth;
let item = self.item;
- let extend = |obligation: traits::PredicateObligation<'tcx>| {
- let mut cause = cause.clone();
- if let Some(parent_trait_pred) = obligation.predicate.to_opt_poly_trait_pred() {
- let derived_cause = traits::DerivedObligationCause {
+ let extend = |traits::PredicateObligation { predicate, mut cause, .. }| {
+ if let Some(parent_trait_pred) = predicate.to_opt_poly_trait_pred() {
+ cause = cause.derived_cause(
parent_trait_pred,
- parent_code: obligation.cause.clone_code(),
- };
- *cause.make_mut_code() =
- traits::ObligationCauseCode::DerivedObligation(derived_cause);
+ traits::ObligationCauseCode::DerivedObligation,
+ );
}
extend_cause_with_original_assoc_item_obligation(
- tcx,
- trait_ref,
- item,
- &mut cause,
- obligation.predicate,
+ tcx, trait_ref, item, &mut cause, predicate,
);
- traits::Obligation::with_depth(cause, depth, param_env, obligation.predicate)
+ traits::Obligation::with_depth(cause, depth, param_env, predicate)
};
if let Elaborate::All = elaborate {
})
.filter(|(_, arg)| !arg.has_escaping_bound_vars())
.map(|(i, arg)| {
- let mut new_cause = cause.clone();
+ let mut cause = traits::ObligationCause::misc(self.span, self.body_id);
// The first subst is the self ty - use the correct span for it.
if i == 0 {
if let Some(hir::ItemKind::Impl(hir::Impl { self_ty, .. })) =
item.map(|i| &i.kind)
{
- new_cause.span = self_ty.span;
+ cause.span = self_ty.span;
}
}
traits::Obligation::with_depth(
- new_cause,
+ cause,
depth,
param_env,
ty::Binder::dummy(ty::PredicateKind::WellFormed(arg)).to_predicate(tcx),
GenericArgKind::Lifetime(_) => continue,
GenericArgKind::Const(constant) => {
- match constant.val() {
+ match constant.kind() {
ty::ConstKind::Unevaluated(uv) => {
let obligations = self.nominal_obligations(uv.def.did, uv.substs);
self.out.extend(obligations);
let cause = self.cause(traits::MiscObligation);
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
- val: ty::ConstKind::Infer(resolved),
+ kind: ty::ConstKind::Infer(resolved),
ty: constant.ty(),
});
self.out.push(traits::Obligation::with_depth(
// generators don't take arguments.
}
- ty::Closure(_, substs) => {
+ ty::Closure(did, substs) => {
// Only check the upvar types for WF, not the rest
// of the types within. This is needed because we
// capture the signature and it may not be WF
// can cause compiler crashes when the user abuses unsafe
// code to procure such a closure.
// See src/test/ui/type-alias-impl-trait/wf_check_closures.rs
- // We should be checking the nominal_obligations here, but that caused
- // a regression in https://github.com/rust-lang/rust/issues/97607
- // The regression will be fixed on nightly, but the fix is too large
- // to be backported.
+ let obligations = self.nominal_obligations(did, substs);
+ self.out.extend(obligations);
}
ty::FnPtr(_) => {