Track WellFormed
obligations with an appropriate cause, instead of MiscObligation
This commit is contained in:
parent
af10a456c1
commit
385c79379c
6 changed files with 14 additions and 14 deletions
|
@ -271,7 +271,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn normalize(mut self) -> Vec<traits::PredicateObligation<'tcx>> {
|
fn normalize(mut self) -> Vec<traits::PredicateObligation<'tcx>> {
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
let infcx = &mut self.infcx;
|
let infcx = &mut self.infcx;
|
||||||
let param_env = self.param_env;
|
let param_env = self.param_env;
|
||||||
let mut obligations = Vec::with_capacity(self.out.len());
|
let mut obligations = Vec::with_capacity(self.out.len());
|
||||||
|
@ -385,7 +385,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
self.out.extend(obligations);
|
self.out.extend(obligations);
|
||||||
|
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
let param_env = self.param_env;
|
let param_env = self.param_env;
|
||||||
let depth = self.recursion_depth;
|
let depth = self.recursion_depth;
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
let predicate =
|
let predicate =
|
||||||
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
|
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
|
||||||
.to_predicate(self.tcx());
|
.to_predicate(self.tcx());
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
self.out.push(traits::Obligation::with_depth(
|
self.out.push(traits::Obligation::with_depth(
|
||||||
cause,
|
cause,
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
|
@ -457,7 +457,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
let resolved = self.infcx.shallow_resolve(infer);
|
let resolved = self.infcx.shallow_resolve(infer);
|
||||||
// the `InferConst` changed, meaning that we made progress.
|
// the `InferConst` changed, meaning that we made progress.
|
||||||
if resolved != infer {
|
if resolved != infer {
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
|
|
||||||
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
|
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
|
||||||
kind: ty::ConstKind::Infer(resolved),
|
kind: ty::ConstKind::Infer(resolved),
|
||||||
|
@ -648,7 +648,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
|
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
|
||||||
|
|
||||||
if !defer_to_coercion {
|
if !defer_to_coercion {
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
let component_traits = data.auto_traits().chain(data.principal_def_id());
|
let component_traits = data.auto_traits().chain(data.principal_def_id());
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
self.out.extend(component_traits.map(|did| {
|
self.out.extend(component_traits.map(|did| {
|
||||||
|
@ -679,7 +679,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
||||||
let ty = self.infcx.shallow_resolve(ty);
|
let ty = self.infcx.shallow_resolve(ty);
|
||||||
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
|
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
|
||||||
// Not yet resolved, but we've made progress.
|
// Not yet resolved, but we've made progress.
|
||||||
let cause = self.cause(traits::MiscObligation);
|
let cause = self.cause(traits::WellFormed(None));
|
||||||
self.out.push(traits::Obligation::with_depth(
|
self.out.push(traits::Obligation::with_depth(
|
||||||
cause,
|
cause,
|
||||||
self.recursion_depth,
|
self.recursion_depth,
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// we must check that return type of called functions is WF:
|
// we must check that return type of called functions is WF:
|
||||||
self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation);
|
self.register_wf_obligation(output.into(), call_expr.span, traits::WellFormed(None));
|
||||||
|
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
|
@ -496,7 +496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
|
|
||||||
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
|
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
|
||||||
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
|
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
|
||||||
self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
|
self.register_wf_obligation(t.into(), ast_t.span, traits::WellFormed(None));
|
||||||
t
|
t
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.register_wf_obligation(
|
self.register_wf_obligation(
|
||||||
c.into(),
|
c.into(),
|
||||||
self.tcx.hir().span(ast_c.hir_id),
|
self.tcx.hir().span(ast_c.hir_id),
|
||||||
ObligationCauseCode::MiscObligation,
|
ObligationCauseCode::WellFormed(None),
|
||||||
);
|
);
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
self.register_wf_obligation(
|
self.register_wf_obligation(
|
||||||
c.into(),
|
c.into(),
|
||||||
self.tcx.hir().span(ast_c.hir_id),
|
self.tcx.hir().span(ast_c.hir_id),
|
||||||
ObligationCauseCode::MiscObligation,
|
ObligationCauseCode::WellFormed(None),
|
||||||
);
|
);
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
for arg in substs.iter().filter(|arg| {
|
for arg in substs.iter().filter(|arg| {
|
||||||
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
|
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
|
||||||
}) {
|
}) {
|
||||||
self.register_wf_obligation(arg, expr.span, traits::MiscObligation);
|
self.register_wf_obligation(arg, expr.span, traits::WellFormed(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -501,7 +501,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
||||||
// the function type must also be well-formed (this is not
|
// the function type must also be well-formed (this is not
|
||||||
// implied by the substs being well-formed because of inherent
|
// implied by the substs being well-formed because of inherent
|
||||||
// impls and late-bound regions - see issue #28609).
|
// impls and late-bound regions - see issue #28609).
|
||||||
self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation);
|
self.register_wf_obligation(fty.into(), self.span, traits::WellFormed(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1180,7 +1180,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
|
||||||
fcx.register_bound(
|
fcx.register_bound(
|
||||||
item_ty,
|
item_ty,
|
||||||
tcx.require_lang_item(LangItem::Sized, None),
|
tcx.require_lang_item(LangItem::Sized, None),
|
||||||
traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
|
traits::ObligationCause::new(ty_span, fcx.body_id, traits::WellFormed(None)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ fn diagnostic_hir_wf_check<'tcx>(
|
||||||
let cause = traits::ObligationCause::new(
|
let cause = traits::ObligationCause::new(
|
||||||
ty.span,
|
ty.span,
|
||||||
self.hir_id,
|
self.hir_id,
|
||||||
traits::ObligationCauseCode::MiscObligation,
|
traits::ObligationCauseCode::WellFormed(None),
|
||||||
);
|
);
|
||||||
fulfill.register_predicate_obligation(
|
fulfill.register_predicate_obligation(
|
||||||
&infcx,
|
&infcx,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue