span: Span,
loc: Option<WellFormedLoc>,
arg: ty::GenericArg<'tcx>,
- override_constness: Option<hir::Constness>,
) {
let cause =
traits::ObligationCause::new(span, self.body_id, ObligationCauseCode::WellFormed(loc));
- let param_env = if let Some(constness) = override_constness {
- self.param_env.with_constness(constness)
- } else {
- self.param_env
- };
+ // for a type to be WF, we do not need to check if const trait predicates satisfy.
+ let param_env = self.param_env.without_const();
self.ocx.register_obligation(traits::Obligation::new(
cause,
param_env,
ty::AssocKind::Const => {
let ty = tcx.type_of(item.def_id);
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
- wfcx.register_wf_obligation(span, loc, ty.into(), None);
+ wfcx.register_wf_obligation(span, loc, ty.into());
}
ty::AssocKind::Fn => {
let sig = tcx.fn_sig(item.def_id);
if item.defaultness(tcx).has_value() {
let ty = tcx.type_of(item.def_id);
let ty = wfcx.normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
- wfcx.register_wf_obligation(span, loc, ty.into(), None);
+ wfcx.register_wf_obligation(span, loc, ty.into());
}
}
}
field.span,
Some(WellFormedLoc::Ty(field.def_id)),
field.ty.into(),
- None,
)
}
ty_span,
Some(WellFormedLoc::Ty(item_id)),
item_ty.into(),
- None,
);
if forbid_unsized {
wfcx.register_bound(
ast_self_ty.span,
Some(WellFormedLoc::Ty(item.hir_id().expect_owner())),
self_ty.into(),
- None,
);
}
}
tcx.def_span(param.def_id),
None,
ty.into(),
- None,
);
}
}
tcx.def_span(param.def_id),
None,
default_ct.into(),
- None,
);
}
}
assert_eq!(predicates.predicates.len(), predicates.spans.len());
let wf_obligations =
iter::zip(&predicates.predicates, &predicates.spans).flat_map(|(&p, &sp)| {
- traits::wf::predicate_obligations(infcx, wfcx.param_env, wfcx.body_id, p, sp)
+ traits::wf::predicate_obligations(infcx, wfcx.param_env.without_const(), wfcx.body_id, p, sp)
});
let obligations: Vec<_> = wf_obligations.chain(default_obligations).collect();
ty.span,
Some(WellFormedLoc::Param { function: def_id, param_idx: i.try_into().unwrap() }),
input_ty.into(),
- None,
);
}
hir_decl.output.span(),
None,
sig.output().into(),
- Some(hir::Constness::NotConst),
);
check_where_clauses(wfcx, span, def_id);