Skip to content

Commit 385c793

Browse files
committed
Track WellFormed obligations with an appropriate cause, instead of MiscObligation
1 parent af10a45 commit 385c793

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

Diff for: compiler/rustc_trait_selection/src/traits/wf.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
271271
}
272272

273273
fn normalize(mut self) -> Vec<traits::PredicateObligation<'tcx>> {
274-
let cause = self.cause(traits::MiscObligation);
274+
let cause = self.cause(traits::WellFormed(None));
275275
let infcx = &mut self.infcx;
276276
let param_env = self.param_env;
277277
let mut obligations = Vec::with_capacity(self.out.len());
@@ -385,7 +385,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
385385
self.out.extend(obligations);
386386

387387
let tcx = self.tcx();
388-
let cause = self.cause(traits::MiscObligation);
388+
let cause = self.cause(traits::WellFormed(None));
389389
let param_env = self.param_env;
390390
let depth = self.recursion_depth;
391391

@@ -445,7 +445,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
445445
let predicate =
446446
ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(uv.shrink()))
447447
.to_predicate(self.tcx());
448-
let cause = self.cause(traits::MiscObligation);
448+
let cause = self.cause(traits::WellFormed(None));
449449
self.out.push(traits::Obligation::with_depth(
450450
cause,
451451
self.recursion_depth,
@@ -457,7 +457,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
457457
let resolved = self.infcx.shallow_resolve(infer);
458458
// the `InferConst` changed, meaning that we made progress.
459459
if resolved != infer {
460-
let cause = self.cause(traits::MiscObligation);
460+
let cause = self.cause(traits::WellFormed(None));
461461

462462
let resolved_constant = self.infcx.tcx.mk_const(ty::ConstS {
463463
kind: ty::ConstKind::Infer(resolved),
@@ -648,7 +648,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
648648
let defer_to_coercion = self.tcx().features().object_safe_for_dispatch;
649649

650650
if !defer_to_coercion {
651-
let cause = self.cause(traits::MiscObligation);
651+
let cause = self.cause(traits::WellFormed(None));
652652
let component_traits = data.auto_traits().chain(data.principal_def_id());
653653
let tcx = self.tcx();
654654
self.out.extend(component_traits.map(|did| {
@@ -679,7 +679,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
679679
let ty = self.infcx.shallow_resolve(ty);
680680
if let ty::Infer(ty::TyVar(_)) = ty.kind() {
681681
// Not yet resolved, but we've made progress.
682-
let cause = self.cause(traits::MiscObligation);
682+
let cause = self.cause(traits::WellFormed(None));
683683
self.out.push(traits::Obligation::with_depth(
684684
cause,
685685
self.recursion_depth,

Diff for: compiler/rustc_typeck/src/check/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
117117
};
118118

119119
// we must check that return type of called functions is WF:
120-
self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation);
120+
self.register_wf_obligation(output.into(), call_expr.span, traits::WellFormed(None));
121121

122122
output
123123
}

Diff for: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
496496

497497
pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
498498
let t = <dyn AstConv<'_>>::ast_ty_to_ty(self, ast_t);
499-
self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
499+
self.register_wf_obligation(t.into(), ast_t.span, traits::WellFormed(None));
500500
t
501501
}
502502

@@ -526,7 +526,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
526526
self.register_wf_obligation(
527527
c.into(),
528528
self.tcx.hir().span(ast_c.hir_id),
529-
ObligationCauseCode::MiscObligation,
529+
ObligationCauseCode::WellFormed(None),
530530
);
531531
c
532532
}
@@ -544,7 +544,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
544544
self.register_wf_obligation(
545545
c.into(),
546546
self.tcx.hir().span(ast_c.hir_id),
547-
ObligationCauseCode::MiscObligation,
547+
ObligationCauseCode::WellFormed(None),
548548
);
549549
c
550550
}
@@ -607,7 +607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
607607
for arg in substs.iter().filter(|arg| {
608608
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
609609
}) {
610-
self.register_wf_obligation(arg, expr.span, traits::MiscObligation);
610+
self.register_wf_obligation(arg, expr.span, traits::WellFormed(None));
611611
}
612612
}
613613

Diff for: compiler/rustc_typeck/src/check/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
501501
// the function type must also be well-formed (this is not
502502
// implied by the substs being well-formed because of inherent
503503
// impls and late-bound regions - see issue #28609).
504-
self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation);
504+
self.register_wf_obligation(fty.into(), self.span, traits::WellFormed(None));
505505
}
506506

507507
///////////////////////////////////////////////////////////////////////////

Diff for: compiler/rustc_typeck/src/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
11801180
fcx.register_bound(
11811181
item_ty,
11821182
tcx.require_lang_item(LangItem::Sized, None),
1183-
traits::ObligationCause::new(ty_span, fcx.body_id, traits::MiscObligation),
1183+
traits::ObligationCause::new(ty_span, fcx.body_id, traits::WellFormed(None)),
11841184
);
11851185
}
11861186

Diff for: compiler/rustc_typeck/src/hir_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn diagnostic_hir_wf_check<'tcx>(
7272
let cause = traits::ObligationCause::new(
7373
ty.span,
7474
self.hir_id,
75-
traits::ObligationCauseCode::MiscObligation,
75+
traits::ObligationCauseCode::WellFormed(None),
7676
);
7777
fulfill.register_predicate_obligation(
7878
&infcx,

0 commit comments

Comments
 (0)