about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-05-26 23:12:01 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-06-02 15:02:36 +0200
commitef4d2c10430c941619ccc517e709f093a4ea9689 (patch)
tree4df315a64f5df7136c490d6afdaa811e7d54d132
parent81831e124e002188d95d690ea090067b3653055f (diff)
downloadrust-ef4d2c10430c941619ccc517e709f093a4ea9689.tar.gz
rust-ef4d2c10430c941619ccc517e709f093a4ea9689.zip
change WellFormed predicate to GenericArg
-rw-r--r--src/librustc_infer/infer/combine.rs2
-rw-r--r--src/librustc_infer/infer/outlives/mod.rs3
-rw-r--r--src/librustc_infer/traits/util.rs5
-rw-r--r--src/librustc_lint/builtin.rs1
-rw-r--r--src/librustc_middle/ty/mod.rs16
-rw-r--r--src/librustc_middle/ty/print/pretty.rs5
-rw-r--r--src/librustc_middle/ty/structural_impls.rs6
-rw-r--r--src/librustc_mir/borrow_check/type_check/mod.rs6
-rw-r--r--src/librustc_mir/transform/qualify_min_const_fn.rs3
-rw-r--r--src/librustc_trait_selection/opaque_types.rs3
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/mod.rs32
-rw-r--r--src/librustc_trait_selection/traits/fulfill.rs21
-rw-r--r--src/librustc_trait_selection/traits/object_safety.rs6
-rw-r--r--src/librustc_trait_selection/traits/select.rs18
-rw-r--r--src/librustc_trait_selection/traits/wf.rs118
-rw-r--r--src/librustc_traits/chalk/lowering.rs48
-rw-r--r--src/librustc_traits/implied_outlives_bounds.rs15
-rw-r--r--src/librustc_traits/normalize_erasing_regions.rs3
-rw-r--r--src/librustc_traits/type_op.rs4
-rw-r--r--src/librustc_typeck/check/callee.rs2
-rw-r--r--src/librustc_typeck/check/method/confirm.rs2
-rw-r--r--src/librustc_typeck/check/method/mod.rs2
-rw-r--r--src/librustc_typeck/check/method/probe.rs3
-rw-r--r--src/librustc_typeck/check/mod.rs57
-rw-r--r--src/librustc_typeck/check/wfcheck.rs18
-rw-r--r--src/librustc_typeck/impl_wf_check/min_specialization.rs7
-rw-r--r--src/librustc_typeck/outlives/explicit.rs3
-rw-r--r--src/librustdoc/clean/mod.rs3
28 files changed, 157 insertions, 255 deletions
diff --git a/src/librustc_infer/infer/combine.rs b/src/librustc_infer/infer/combine.rs
index 70a2122a9ea..4ef4ed47cb1 100644
--- a/src/librustc_infer/infer/combine.rs
+++ b/src/librustc_infer/infer/combine.rs
@@ -307,7 +307,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
             self.obligations.push(Obligation::new(
                 self.trace.cause.clone(),
                 self.param_env,
-                ty::PredicateKind::WellFormed(b_ty).to_predicate(self.infcx.tcx),
+                ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
             ));
         }
 
diff --git a/src/librustc_infer/infer/outlives/mod.rs b/src/librustc_infer/infer/outlives/mod.rs
index ad8e44a6c1d..fd3b38e9d67 100644
--- a/src/librustc_infer/infer/outlives/mod.rs
+++ b/src/librustc_infer/infer/outlives/mod.rs
@@ -20,8 +20,7 @@ pub fn explicit_outlives_bounds<'tcx>(
         | ty::PredicateKind::ClosureKind(..)
         | ty::PredicateKind::TypeOutlives(..)
         | ty::PredicateKind::ConstEvaluatable(..)
-        | ty::PredicateKind::ConstEquate(..)
-        | ty::PredicateKind::WellFormedConst(..) => None,
+        | ty::PredicateKind::ConstEquate(..) => None,
         ty::PredicateKind::RegionOutlives(ref data) => data
             .no_bound_vars()
             .map(|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a)),
diff --git a/src/librustc_infer/traits/util.rs b/src/librustc_infer/traits/util.rs
index 1aaa07d23cc..8081cac0067 100644
--- a/src/librustc_infer/traits/util.rs
+++ b/src/librustc_infer/traits/util.rs
@@ -45,8 +45,6 @@ pub fn anonymize_predicate<'tcx>(
         }
 
         ty::PredicateKind::ConstEquate(c1, c2) => ty::PredicateKind::ConstEquate(c1, c2),
-
-        ty::PredicateKind::WellFormedConst(ct) => ty::PredicateKind::WellFormedConst(ct),
     };
 
     if new != *kind { new.to_predicate(tcx) } else { pred }
@@ -206,9 +204,6 @@ impl Elaborator<'tcx> {
                 // Currently, we do not elaborate const-equate
                 // predicates.
             }
-            ty::PredicateKind::WellFormedConst(..) => {
-                // Currently, we do not elaborate WF predicates.
-            }
             ty::PredicateKind::RegionOutlives(..) => {
                 // Nothing to elaborate from `'a: 'b`.
             }
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index bde761b01c3..e17e8b7b964 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -1218,7 +1218,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints {
                     Projection(..) |
                     // Ignore bounds that a user can't type
                     WellFormed(..) |
-                    WellFormedConst(..) |
                     ObjectSafe(..) |
                     ClosureKind(..) |
                     Subtype(..) |
diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs
index 554553dc6b4..a34cff06bc1 100644
--- a/src/librustc_middle/ty/mod.rs
+++ b/src/librustc_middle/ty/mod.rs
@@ -14,7 +14,7 @@ use crate::mir::Body;
 use crate::mir::GeneratorLayout;
 use crate::traits::{self, Reveal};
 use crate::ty;
-use crate::ty::subst::{InternalSubsts, Subst, SubstsRef};
+use crate::ty::subst::{GenericArg, InternalSubsts, Subst, SubstsRef};
 use crate::ty::util::{Discr, IntTypeExt};
 use rustc_ast::ast;
 use rustc_attr as attr;
@@ -1061,7 +1061,7 @@ pub enum PredicateKind<'tcx> {
     Projection(PolyProjectionPredicate<'tcx>),
 
     /// No syntax: `T` well-formed.
-    WellFormed(Ty<'tcx>),
+    WellFormed(GenericArg<'tcx>),
 
     /// Trait must be object-safe.
     ObjectSafe(DefId),
@@ -1079,9 +1079,6 @@ pub enum PredicateKind<'tcx> {
 
     /// Constants must be equal. The first component is the const that is expected.
     ConstEquate(&'tcx Const<'tcx>, &'tcx Const<'tcx>),
-
-    /// Constant must be well formed.
-    WellFormedConst(&'tcx Const<'tcx>),
 }
 
 /// The crate outlives map is computed during typeck and contains the
@@ -1198,9 +1195,6 @@ impl<'tcx> Predicate<'tcx> {
             PredicateKind::ConstEquate(c1, c2) => {
                 PredicateKind::ConstEquate(c1.subst(tcx, substs), c2.subst(tcx, substs))
             }
-            PredicateKind::WellFormedConst(c) => {
-                PredicateKind::WellFormedConst(c.subst(tcx, substs))
-            }
         };
 
         if new != *kind { new.to_predicate(tcx) } else { self }
@@ -1392,8 +1386,7 @@ impl<'tcx> Predicate<'tcx> {
             | PredicateKind::ClosureKind(..)
             | PredicateKind::TypeOutlives(..)
             | PredicateKind::ConstEvaluatable(..)
-            | PredicateKind::ConstEquate(..)
-            | PredicateKind::WellFormedConst(..) => None,
+            | PredicateKind::ConstEquate(..) => None,
         }
     }
 
@@ -1408,8 +1401,7 @@ impl<'tcx> Predicate<'tcx> {
             | PredicateKind::ObjectSafe(..)
             | PredicateKind::ClosureKind(..)
             | PredicateKind::ConstEvaluatable(..)
-            | PredicateKind::ConstEquate(..)
-            | PredicateKind::WellFormedConst(..) => None,
+            | PredicateKind::ConstEquate(..) => None,
         }
     }
 }
diff --git a/src/librustc_middle/ty/print/pretty.rs b/src/librustc_middle/ty/print/pretty.rs
index 6eb11b0c942..90fb1981617 100644
--- a/src/librustc_middle/ty/print/pretty.rs
+++ b/src/librustc_middle/ty/print/pretty.rs
@@ -2031,7 +2031,7 @@ define_print_and_forward_display! {
             ty::PredicateKind::RegionOutlives(predicate) => p!(print(predicate)),
             ty::PredicateKind::TypeOutlives(predicate) => p!(print(predicate)),
             ty::PredicateKind::Projection(predicate) => p!(print(predicate)),
-            ty::PredicateKind::WellFormed(ty) => p!(print(ty), write(" well-formed")),
+            ty::PredicateKind::WellFormed(arg) => p!(print(arg), write(" well-formed")),
             &ty::PredicateKind::ObjectSafe(trait_def_id) => {
                 p!(write("the trait `"),
                    print_def_path(trait_def_id, &[]),
@@ -2054,9 +2054,6 @@ define_print_and_forward_display! {
                    print(c2),
                    write("`"))
             }
-            ty::PredicateKind::WellFormedConst(c) => {
-                p!(print(c), write(" well-formed"))
-            }
         }
     }
 
diff --git a/src/librustc_middle/ty/structural_impls.rs b/src/librustc_middle/ty/structural_impls.rs
index 19a2e89ca41..6c1a524b7fe 100644
--- a/src/librustc_middle/ty/structural_impls.rs
+++ b/src/librustc_middle/ty/structural_impls.rs
@@ -236,7 +236,7 @@ impl fmt::Debug for ty::PredicateKind<'tcx> {
             ty::PredicateKind::RegionOutlives(ref pair) => pair.fmt(f),
             ty::PredicateKind::TypeOutlives(ref pair) => pair.fmt(f),
             ty::PredicateKind::Projection(ref pair) => pair.fmt(f),
-            ty::PredicateKind::WellFormed(ty) => write!(f, "WellFormed({:?})", ty),
+            ty::PredicateKind::WellFormed(data) => write!(f, "WellFormed({:?})", data),
             ty::PredicateKind::ObjectSafe(trait_def_id) => {
                 write!(f, "ObjectSafe({:?})", trait_def_id)
             }
@@ -247,7 +247,6 @@ impl fmt::Debug for ty::PredicateKind<'tcx> {
                 write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
             }
             ty::PredicateKind::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
-            ty::PredicateKind::WellFormedConst(c) => write!(f, "WellFormedConst({:?})", c),
         }
     }
 }
@@ -508,9 +507,6 @@ impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
             ty::PredicateKind::ConstEquate(c1, c2) => {
                 tcx.lift(&(c1, c2)).map(|(c1, c2)| ty::PredicateKind::ConstEquate(c1, c2))
             }
-            ty::PredicateKind::WellFormedConst(c) => {
-                tcx.lift(&c).map(ty::PredicateKind::WellFormedConst)
-            }
         }
     }
 }
diff --git a/src/librustc_mir/borrow_check/type_check/mod.rs b/src/librustc_mir/borrow_check/type_check/mod.rs
index fdc3b291ba4..377a0b6f25c 100644
--- a/src/librustc_mir/borrow_check/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/type_check/mod.rs
@@ -1016,7 +1016,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
                     }
 
                     self.prove_predicate(
-                        ty::PredicateKind::WellFormed(inferred_ty).to_predicate(self.tcx()),
+                        ty::PredicateKind::WellFormed(inferred_ty.into()).to_predicate(self.tcx()),
                         Locations::All(span),
                         ConstraintCategory::TypeAnnotation,
                     );
@@ -1268,7 +1268,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
                     obligations.obligations.push(traits::Obligation::new(
                         ObligationCause::dummy(),
                         param_env,
-                        ty::PredicateKind::WellFormed(revealed_ty).to_predicate(infcx.tcx),
+                        ty::PredicateKind::WellFormed(revealed_ty.into()).to_predicate(infcx.tcx),
                     ));
                     obligations.add(
                         infcx
@@ -1612,7 +1612,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
                 self.check_call_dest(body, term, &sig, destination, term_location);
 
                 self.prove_predicates(
-                    sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty)),
+                    sig.inputs_and_output.iter().map(|ty| ty::PredicateKind::WellFormed(ty.into())),
                     term_location.to_locations(),
                     ConstraintCategory::Boring,
                 );
diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs
index 22959c6a3df..5615aa84eec 100644
--- a/src/librustc_mir/transform/qualify_min_const_fn.rs
+++ b/src/librustc_mir/transform/qualify_min_const_fn.rs
@@ -29,8 +29,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId, body: &'a Body<'tcx>) -
                 | ty::PredicateKind::WellFormed(_)
                 | ty::PredicateKind::Projection(_)
                 | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::WellFormedConst(..) => continue,
+                | ty::PredicateKind::ConstEquate(..) => continue,
                 ty::PredicateKind::ObjectSafe(_) => {
                     bug!("object safe predicate on function: {:#?}", predicate)
                 }
diff --git a/src/librustc_trait_selection/opaque_types.rs b/src/librustc_trait_selection/opaque_types.rs
index 8bbcfb1ade5..f78a6207a3a 100644
--- a/src/librustc_trait_selection/opaque_types.rs
+++ b/src/librustc_trait_selection/opaque_types.rs
@@ -1277,8 +1277,7 @@ crate fn required_region_bounds(
                 | ty::PredicateKind::ClosureKind(..)
                 | ty::PredicateKind::RegionOutlives(..)
                 | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::WellFormedConst(..) => None,
+                | ty::PredicateKind::ConstEquate(..) => None,
                 ty::PredicateKind::TypeOutlives(predicate) => {
                     // Search for a bound of the form `erased_self_ty
                     // : 'a`, but be wary of something like `for<'a>
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs
index 1134cafbae4..41811bf44b1 100644
--- a/src/librustc_trait_selection/traits/error_reporting/mod.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs
@@ -19,6 +19,7 @@ use rustc_hir::Node;
 use rustc_middle::mir::interpret::ErrorHandled;
 use rustc_middle::ty::error::ExpectedFound;
 use rustc_middle::ty::fold::TypeFolder;
+use rustc_middle::ty::subst::GenericArgKind;
 use rustc_middle::ty::{
     self, fast_reject, AdtKind, SubtypePredicate, ToPolyTraitRef, ToPredicate, Ty, TyCtxt,
     TypeFoldable, WithConstness,
@@ -610,15 +611,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                         }
                     }
 
-                    ty::PredicateKind::WellFormedConst(ct) => {
-                        // Const WF predicates cannot themselves make
-                        // errors. They can only block due to
-                        // ambiguity; otherwise, they always
-                        // degenerate into other obligations
-                        // (which may fail).
-                        span_bug!(span, "const WF predicate not satisfied for {:?}", ct);
-                    }
-
                     ty::PredicateKind::ConstEvaluatable(..) => {
                         // Errors for `ConstEvaluatable` predicates show up as
                         // `SelectionError::ConstEvalFailure`,
@@ -1540,22 +1532,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
                 err
             }
 
-            ty::PredicateKind::WellFormed(ty) => {
+            ty::PredicateKind::WellFormed(arg) => {
                 // Same hacky approach as above to avoid deluging user
                 // with error messages.
-                if ty.references_error() || self.tcx.sess.has_errors() {
+                if arg.references_error() || self.tcx.sess.has_errors() {
                     return;
                 }
-                self.need_type_info_err(body_id, span, ty, ErrorCode::E0282)
-            }
 
-            ty::PredicateKind::WellFormedConst(ct) => {
-                // Same hacky approach as above to avoid deluging user
-                // with error messages.
-                if ct.references_error() || self.tcx.sess.has_errors() {
-                    return;
+                match arg.unpack() {
+                    GenericArgKind::Lifetime(lt) => {
+                        span_bug!(span, "unexpected well formed predicate: {:?}", lt)
+                    }
+                    GenericArgKind::Type(ty) => {
+                        self.need_type_info_err(body_id, span, ty, ErrorCode::E0282)
+                    }
+                    GenericArgKind::Const(ct) => {
+                        self.need_type_info_err_const(body_id, span, ct, ErrorCode::E0282)
+                    }
                 }
-                self.need_type_info_err_const(body_id, span, ct, ErrorCode::E0282)
             }
 
             ty::PredicateKind::Subtype(ref data) => {
diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs
index 8ab81246e7d..51c62dbb88c 100644
--- a/src/librustc_trait_selection/traits/fulfill.rs
+++ b/src/librustc_trait_selection/traits/fulfill.rs
@@ -459,38 +459,23 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
                 }
             }
 
-            &ty::PredicateKind::WellFormed(ty) => {
+            &ty::PredicateKind::WellFormed(arg) => {
                 match wf::obligations(
                     self.selcx.infcx(),
                     obligation.param_env,
                     obligation.cause.body_id,
-                    ty,
+                    arg,
                     obligation.cause.span,
                 ) {
                     None => {
                         pending_obligation.stalled_on =
-                            vec![TyOrConstInferVar::maybe_from_ty(ty).unwrap()];
+                            vec![TyOrConstInferVar::maybe_from_generic_arg(arg).unwrap()];
                         ProcessResult::Unchanged
                     }
                     Some(os) => ProcessResult::Changed(mk_pending(os)),
                 }
             }
 
-            ty::PredicateKind::WellFormedConst(constant) => match wf::const_obligations(
-                self.selcx.infcx(),
-                obligation.param_env,
-                obligation.cause.body_id,
-                constant,
-                obligation.cause.span,
-            ) {
-                Some(predicates) => ProcessResult::Changed(mk_pending(predicates)),
-                None => {
-                    pending_obligation.stalled_on =
-                        vec![TyOrConstInferVar::maybe_from_const(constant).unwrap()];
-                    ProcessResult::Unchanged
-                }
-            },
-
             &ty::PredicateKind::Subtype(subtype) => {
                 match self.selcx.infcx().subtype_predicate(
                     &obligation.cause,
diff --git a/src/librustc_trait_selection/traits/object_safety.rs b/src/librustc_trait_selection/traits/object_safety.rs
index ee7aa6b165d..5befc797a51 100644
--- a/src/librustc_trait_selection/traits/object_safety.rs
+++ b/src/librustc_trait_selection/traits/object_safety.rs
@@ -283,8 +283,7 @@ fn predicates_reference_self(
                 | ty::PredicateKind::ClosureKind(..)
                 | ty::PredicateKind::Subtype(..)
                 | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::WellFormedConst(..) => None,
+                | ty::PredicateKind::ConstEquate(..) => None,
             }
         })
         .collect()
@@ -319,8 +318,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
             | ty::PredicateKind::ClosureKind(..)
             | ty::PredicateKind::TypeOutlives(..)
             | ty::PredicateKind::ConstEvaluatable(..)
-            | ty::PredicateKind::ConstEquate(..)
-            | ty::PredicateKind::WellFormedConst(..) => false,
+            | ty::PredicateKind::ConstEquate(..) => false,
         }
     })
 }
diff --git a/src/librustc_trait_selection/traits/select.rs b/src/librustc_trait_selection/traits/select.rs
index 9dd0592c45f..517433b90ee 100644
--- a/src/librustc_trait_selection/traits/select.rs
+++ b/src/librustc_trait_selection/traits/select.rs
@@ -436,25 +436,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                 }
             }
 
-            &ty::PredicateKind::WellFormed(ty) => match wf::obligations(
+            &ty::PredicateKind::WellFormed(arg) => match wf::obligations(
                 self.infcx,
                 obligation.param_env,
                 obligation.cause.body_id,
-                ty,
-                obligation.cause.span,
-            ) {
-                Some(mut obligations) => {
-                    self.add_depth(obligations.iter_mut(), obligation.recursion_depth);
-                    self.evaluate_predicates_recursively(previous_stack, obligations.into_iter())
-                }
-                None => Ok(EvaluatedToAmbig),
-            },
-
-            ty::PredicateKind::WellFormedConst(constant) => match wf::const_obligations(
-                self.infcx,
-                obligation.param_env,
-                obligation.cause.body_id,
-                constant,
+                arg,
                 obligation.cause.span,
             ) {
                 Some(mut obligations) => {
diff --git a/src/librustc_trait_selection/traits/wf.rs b/src/librustc_trait_selection/traits/wf.rs
index 458a6f5b88f..dde50a84952 100644
--- a/src/librustc_trait_selection/traits/wf.rs
+++ b/src/librustc_trait_selection/traits/wf.rs
@@ -9,9 +9,9 @@ use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstnes
 use rustc_span::Span;
 use std::rc::Rc;
 
-/// Returns the set of obligations needed to make `ty` well-formed.
-/// If `ty` contains unresolved inference variables, this may include
-/// further WF obligations. However, if `ty` IS an unresolved
+/// Returns the set of obligations needed to make `arg` well-formed.
+/// If `arg` contains unresolved inference variables, this may include
+/// further WF obligations. However, if `arg` IS an unresolved
 /// inference variable, returns `None`, because we are not able to
 /// make any progress at all. This is to prevent "livelock" where we
 /// say "$0 is WF if $0 is WF".
@@ -19,59 +19,51 @@ pub fn obligations<'a, 'tcx>(
     infcx: &InferCtxt<'a, 'tcx>,
     param_env: ty::ParamEnv<'tcx>,
     body_id: hir::HirId,
-    ty: Ty<'tcx>,
+    arg: GenericArg<'tcx>,
     span: Span,
 ) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
     // Handle the "livelock" case (see comment above) by bailing out if necessary.
-    let ty = match ty.kind {
-        ty::Infer(ty::TyVar(_)) => {
-            let resolved_ty = infcx.shallow_resolve(ty);
-            if resolved_ty == ty {
-                // No progress, bail out to prevent "livelock".
-                return None;
-            }
+    let arg = match arg.unpack() {
+        GenericArgKind::Type(ty) => {
+            match ty.kind {
+                ty::Infer(ty::TyVar(_)) => {
+                    let resolved_ty = infcx.shallow_resolve(ty);
+                    if resolved_ty == ty {
+                        // No progress, bail out to prevent "livelock".
+                        return None;
+                    }
 
-            resolved_ty
+                    resolved_ty
+                }
+                _ => ty,
+            }
+            .into()
         }
-        _ => ty,
-    };
-
-    let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None };
-    wf.compute(ty.into());
-    debug!("wf::obligations({:?}, body_id={:?}) = {:?}", ty, body_id, wf.out);
-
-    let result = wf.normalize();
-    debug!("wf::obligations({:?}, body_id={:?}) ~~> {:?}", ty, body_id, result);
-    Some(result)
-}
+        GenericArgKind::Const(ct) => {
+            match ct.val {
+                ty::ConstKind::Infer(infer) => {
+                    let resolved = infcx.shallow_resolve(infer);
+                    if resolved == infer {
+                        // No progress.
+                        return None;
+                    }
 
-/// Returns the set of obligations needed to make the `constant` well-formed.
-pub fn const_obligations<'a, 'tcx>(
-    infcx: &InferCtxt<'a, 'tcx>,
-    param_env: ty::ParamEnv<'tcx>,
-    body_id: hir::HirId,
-    constant: &'tcx ty::Const<'tcx>,
-    span: Span,
-) -> Option<Vec<traits::PredicateObligation<'tcx>>> {
-    let constant = match constant.val {
-        ty::ConstKind::Infer(infer) => {
-            let resolved = infcx.shallow_resolve(infer);
-            if resolved == infer {
-                // No progress.
-                return None;
+                    infcx.tcx.mk_const(ty::Const { val: ty::ConstKind::Infer(resolved), ty: ct.ty })
+                }
+                _ => ct,
             }
-
-            infcx.tcx.mk_const(ty::Const { val: ty::ConstKind::Infer(resolved), ..*constant })
+            .into()
         }
-        _ => constant,
+        // There is nothing we have to do for lifetimes.
+        GenericArgKind::Lifetime(..) => return Some(Vec::new()),
     };
 
     let mut wf = WfPredicates { infcx, param_env, body_id, span, out: vec![], item: None };
-    wf.compute(constant.into());
-    debug!("wf::const obligations({:?}, body_id={:?}) = {:?}", constant, body_id, wf.out);
+    wf.compute(arg);
+    debug!("wf::obligations({:?}, body_id={:?}) = {:?}", arg, body_id, wf.out);
 
     let result = wf.normalize();
-    debug!("wf::const obligations({:?}, body_id={:?}) ~~> {:?}", constant, body_id, result);
+    debug!("wf::obligations({:?}, body_id={:?}) ~~> {:?}", arg, body_id, result);
     Some(result)
 }
 
@@ -115,8 +107,8 @@ pub fn predicate_obligations<'a, 'tcx>(
             wf.compute_projection(t.projection_ty);
             wf.compute(t.ty.into());
         }
-        &ty::PredicateKind::WellFormed(t) => {
-            wf.compute(t.into());
+        &ty::PredicateKind::WellFormed(arg) => {
+            wf.compute(arg);
         }
         ty::PredicateKind::ObjectSafe(_) => {}
         ty::PredicateKind::ClosureKind(..) => {}
@@ -128,17 +120,14 @@ pub fn predicate_obligations<'a, 'tcx>(
             let obligations = wf.nominal_obligations(def_id, substs);
             wf.out.extend(obligations);
 
-            for subst in substs.iter() {
-                wf.compute(subst);
+            for arg in substs.iter() {
+                wf.compute(arg);
             }
         }
         &ty::PredicateKind::ConstEquate(c1, c2) => {
             wf.compute(c1.into());
             wf.compute(c2.into());
         }
-        &ty::PredicateKind::WellFormedConst(constant) => {
-            wf.compute(constant.into());
-        }
     }
 
     wf.normalize()
@@ -306,15 +295,22 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
         }
 
         let tcx = self.tcx();
-        self.out.extend(trait_ref.substs.types().filter(|ty| !ty.has_escaping_bound_vars()).map(
-            |ty| {
-                traits::Obligation::new(
-                    cause.clone(),
-                    param_env,
-                    ty::PredicateKind::WellFormed(ty).to_predicate(tcx),
-                )
-            },
-        ));
+        self.out.extend(
+            trait_ref
+                .substs
+                .iter()
+                .filter(|arg| {
+                    matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
+                })
+                .filter(|arg| !arg.has_escaping_bound_vars())
+                .map(|arg| {
+                    traits::Obligation::new(
+                        cause.clone(),
+                        param_env,
+                        ty::PredicateKind::WellFormed(arg).to_predicate(tcx),
+                    )
+                }),
+        );
     }
 
     /// Pushes the obligations required for `trait_ref::Item` to be WF
@@ -390,7 +386,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                                 self.out.push(traits::Obligation::new(
                                     cause,
                                     self.param_env,
-                                    ty::PredicateKind::WellFormedConst(resolved_constant)
+                                    ty::PredicateKind::WellFormed(resolved_constant.into())
                                         .to_predicate(self.tcx()),
                                 ));
                             }
@@ -594,7 +590,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
                         self.out.push(traits::Obligation::new(
                             cause,
                             param_env,
-                            ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx()),
+                            ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()),
                         ));
                     } else {
                         // Yes, resolved, proceed with the result.
diff --git a/src/librustc_traits/chalk/lowering.rs b/src/librustc_traits/chalk/lowering.rs
index b624598322a..9530b07e47c 100644
--- a/src/librustc_traits/chalk/lowering.rs
+++ b/src/librustc_traits/chalk/lowering.rs
@@ -36,7 +36,7 @@ use rustc_middle::traits::{
     ChalkRustInterner as RustInterner,
 };
 use rustc_middle::ty::fold::TypeFolder;
-use rustc_middle::ty::subst::{GenericArg, SubstsRef};
+use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
 use rustc_middle::ty::{
     self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TyKind, TypeFoldable, TypeVisitor,
 };
@@ -126,8 +126,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
                     | ty::PredicateKind::ClosureKind(..)
                     | ty::PredicateKind::Subtype(..)
                     | ty::PredicateKind::ConstEvaluatable(..)
-                    | ty::PredicateKind::ConstEquate(..)
-                    | ty::PredicateKind::WellFormedConst(..) => {
+                    | ty::PredicateKind::ConstEquate(..) => {
                         bug!("unexpected predicate {}", predicate)
                     }
                 }
@@ -166,24 +165,31 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
                 chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
             }
             ty::PredicateKind::Projection(predicate) => predicate.lower_into(interner),
-            ty::PredicateKind::WellFormed(ty) => match ty.kind {
-                // These types are always WF.
-                ty::Str | ty::Placeholder(..) | ty::Error | ty::Never => {
-                    chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
-                }
+            ty::PredicateKind::WellFormed(arg) => match arg.unpack() {
+                GenericArgKind::Type(ty) => match ty.kind {
+                    // These types are always WF.
+                    ty::Str | ty::Placeholder(..) | ty::Error | ty::Never => {
+                        chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
+                    }
 
-                // FIXME(chalk): Well-formed only if ref lifetime outlives type
-                ty::Ref(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)),
+                    // FIXME(chalk): Well-formed only if ref lifetime outlives type
+                    ty::Ref(..) => chalk_ir::GoalData::All(chalk_ir::Goals::new(interner)),
 
-                ty::Param(..) => panic!("No Params expected."),
+                    ty::Param(..) => panic!("No Params expected."),
 
-                // FIXME(chalk) -- ultimately I think this is what we
-                // want to do, and we just have rules for how to prove
-                // `WellFormed` for everything above, instead of
-                // inlining a bit the rules of the proof here.
-                _ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
-                    chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
-                )),
+                    // FIXME(chalk) -- ultimately I think this is what we
+                    // want to do, and we just have rules for how to prove
+                    // `WellFormed` for everything above, instead of
+                    // inlining a bit the rules of the proof here.
+                    _ => chalk_ir::GoalData::DomainGoal(chalk_ir::DomainGoal::WellFormed(
+                        chalk_ir::WellFormed::Ty(ty.lower_into(interner)),
+                    )),
+                },
+                // FIXME(chalk): handle well formed consts
+                GenericArgKind::Const(..) => {
+                    chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
+                }
+                GenericArgKind::Lifetime(lt) => bug!("unexpect well formed predicate: {:?}", lt),
             },
 
             // FIXME(chalk): other predicates
@@ -194,8 +200,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
             | ty::PredicateKind::ClosureKind(..)
             | ty::PredicateKind::Subtype(..)
             | ty::PredicateKind::ConstEvaluatable(..)
-            | ty::PredicateKind::ConstEquate(..)
-            | ty::PredicateKind::WellFormedConst(..) => {
+            | ty::PredicateKind::ConstEquate(..) => {
                 chalk_ir::GoalData::All(chalk_ir::Goals::new(interner))
             }
         }
@@ -462,8 +467,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
             | ty::PredicateKind::ClosureKind(..)
             | ty::PredicateKind::Subtype(..)
             | ty::PredicateKind::ConstEvaluatable(..)
-            | ty::PredicateKind::ConstEquate(..)
-            | ty::PredicateKind::WellFormedConst(..) => bug!("unexpected predicate {}", &self),
+            | ty::PredicateKind::ConstEquate(..) => bug!("unexpected predicate {}", &self),
         }
     }
 }
diff --git a/src/librustc_traits/implied_outlives_bounds.rs b/src/librustc_traits/implied_outlives_bounds.rs
index 073dfe4d592..651596d0379 100644
--- a/src/librustc_traits/implied_outlives_bounds.rs
+++ b/src/librustc_traits/implied_outlives_bounds.rs
@@ -47,14 +47,14 @@ fn compute_implied_outlives_bounds<'tcx>(
     // process it next. Currently (at least) these resulting
     // predicates are always guaranteed to be a subset of the original
     // type, so we need not fear non-termination.
-    let mut wf_types = vec![ty];
+    let mut wf_args = vec![ty.into()];
 
     let mut implied_bounds = vec![];
 
     let mut fulfill_cx = FulfillmentContext::new();
 
-    while let Some(ty) = wf_types.pop() {
-        // Compute the obligations for `ty` to be well-formed. If `ty` is
+    while let Some(arg) = wf_args.pop() {
+        // Compute the obligations for `arg` to be well-formed. If `arg` is
         // an unresolved inference variable, just substituted an empty set
         // -- because the return type here is going to be things we *add*
         // to the environment, it's always ok for this set to be smaller
@@ -62,7 +62,7 @@ fn compute_implied_outlives_bounds<'tcx>(
         // unresolved inference variables here anyway, but there might be
         // during typeck under some circumstances.)
         let obligations =
-            wf::obligations(infcx, param_env, hir::CRATE_HIR_ID, ty, DUMMY_SP).unwrap_or(vec![]);
+            wf::obligations(infcx, param_env, hir::CRATE_HIR_ID, arg, DUMMY_SP).unwrap_or(vec![]);
 
         // N.B., all of these predicates *ought* to be easily proven
         // true. In fact, their correctness is (mostly) implied by
@@ -101,11 +101,10 @@ fn compute_implied_outlives_bounds<'tcx>(
                 | ty::PredicateKind::ClosureKind(..)
                 | ty::PredicateKind::ObjectSafe(..)
                 | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::WellFormedConst(..) => vec![],
+                | ty::PredicateKind::ConstEquate(..) => vec![],
 
-                ty::PredicateKind::WellFormed(subty) => {
-                    wf_types.push(subty);
+                &ty::PredicateKind::WellFormed(arg) => {
+                    wf_args.push(arg);
                     vec![]
                 }
 
diff --git a/src/librustc_traits/normalize_erasing_regions.rs b/src/librustc_traits/normalize_erasing_regions.rs
index 6a8d81085c5..fcb75142269 100644
--- a/src/librustc_traits/normalize_erasing_regions.rs
+++ b/src/librustc_traits/normalize_erasing_regions.rs
@@ -49,7 +49,6 @@ fn not_outlives_predicate(p: &ty::Predicate<'_>) -> bool {
         | ty::PredicateKind::ClosureKind(..)
         | ty::PredicateKind::Subtype(..)
         | ty::PredicateKind::ConstEvaluatable(..)
-        | ty::PredicateKind::ConstEquate(..)
-        | ty::PredicateKind::WellFormedConst(..) => true,
+        | ty::PredicateKind::ConstEquate(..) => true,
     }
 }
diff --git a/src/librustc_traits/type_op.rs b/src/librustc_traits/type_op.rs
index 22077b49c3b..374ef3fc9c7 100644
--- a/src/librustc_traits/type_op.rs
+++ b/src/librustc_traits/type_op.rs
@@ -140,7 +140,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
             self.relate(self_ty, Variance::Invariant, impl_self_ty)?;
 
             self.prove_predicate(
-                ty::PredicateKind::WellFormed(impl_self_ty).to_predicate(self.tcx()),
+                ty::PredicateKind::WellFormed(impl_self_ty.into()).to_predicate(self.tcx()),
             );
         }
 
@@ -155,7 +155,7 @@ impl AscribeUserTypeCx<'me, 'tcx> {
         // them?  This would only be relevant if some input
         // type were ill-formed but did not appear in `ty`,
         // which...could happen with normalization...
-        self.prove_predicate(ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx()));
+        self.prove_predicate(ty::PredicateKind::WellFormed(ty.into()).to_predicate(self.tcx()));
         Ok(())
     }
 }
diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs
index f4e46a04931..aa316105f7f 100644
--- a/src/librustc_typeck/check/callee.rs
+++ b/src/librustc_typeck/check/callee.rs
@@ -94,7 +94,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         };
 
         // we must check that return type of called functions is WF:
-        self.register_wf_obligation(output, call_expr.span, traits::MiscObligation);
+        self.register_wf_obligation(output.into(), call_expr.span, traits::MiscObligation);
 
         output
     }
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index 48d27387476..007794ce1b7 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -413,7 +413,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
         // the function type must also be well-formed (this is not
         // implied by the substs being well-formed because of inherent
         // impls and late-bound regions - see issue #28609).
-        self.register_wf_obligation(fty, self.span, traits::MiscObligation);
+        self.register_wf_obligation(fty.into(), self.span, traits::MiscObligation);
     }
 
     ///////////////////////////////////////////////////////////////////////////
diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs
index aae02ea0273..ac3fa15417e 100644
--- a/src/librustc_typeck/check/method/mod.rs
+++ b/src/librustc_typeck/check/method/mod.rs
@@ -401,7 +401,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         obligations.push(traits::Obligation::new(
             cause,
             self.param_env,
-            ty::PredicateKind::WellFormed(method_ty).to_predicate(tcx),
+            ty::PredicateKind::WellFormed(method_ty.into()).to_predicate(tcx),
         ));
 
         let callee = MethodCallee { def_id, substs: trait_ref.substs, sig: fn_sig };
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index c17b3d78125..91562d576ea 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -814,8 +814,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                 | ty::PredicateKind::ClosureKind(..)
                 | ty::PredicateKind::TypeOutlives(..)
                 | ty::PredicateKind::ConstEvaluatable(..)
-                | ty::PredicateKind::ConstEquate(..)
-                | ty::PredicateKind::WellFormedConst(..) => None,
+                | ty::PredicateKind::ConstEquate(..) => None,
             });
 
         self.elaborate_bounds(bounds, |this, poly_trait_ref, item| {
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 374ba1c7314..275581318f7 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -121,9 +121,8 @@ use rustc_middle::ty::adjustment::{
 };
 use rustc_middle::ty::fold::{TypeFoldable, TypeFolder};
 use rustc_middle::ty::query::Providers;
-use rustc_middle::ty::subst::{
-    GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSelfTy, UserSubsts,
-};
+use rustc_middle::ty::subst::{self, InternalSubsts, Subst, SubstsRef};
+use rustc_middle::ty::subst::{GenericArgKind, UserSelfTy, UserSubsts};
 use rustc_middle::ty::util::{Discr, IntTypeExt, Representability};
 use rustc_middle::ty::{
     self, AdtKind, CanonicalUserType, Const, GenericParamDefKind, RegionKind, ToPolyTraitRef,
@@ -3333,7 +3332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
     pub fn to_ty(&self, ast_t: &hir::Ty<'_>) -> Ty<'tcx> {
         let t = AstConv::ast_ty_to_ty(self, ast_t);
-        self.register_wf_obligation(t, ast_t.span, traits::MiscObligation);
+        self.register_wf_obligation(t.into(), ast_t.span, traits::MiscObligation);
         t
     }
 
@@ -3353,8 +3352,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     pub fn to_const(&self, ast_c: &hir::AnonConst) -> &'tcx ty::Const<'tcx> {
         let const_def_id = self.tcx.hir().local_def_id(ast_c.hir_id);
         let c = ty::Const::from_anon_const(self.tcx, const_def_id);
-        self.register_wf_const_obligation(
-            c,
+        self.register_wf_obligation(
+            c.into(),
             self.tcx.hir().span(ast_c.hir_id),
             ObligationCauseCode::MiscObligation,
         );
@@ -3394,24 +3393,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     /// outlive the region `r`.
     pub fn register_wf_obligation(
         &self,
-        ty: Ty<'tcx>,
-        span: Span,
-        code: traits::ObligationCauseCode<'tcx>,
-    ) {
-        // WF obligations never themselves fail, so no real need to give a detailed cause:
-        let cause = traits::ObligationCause::new(span, self.body_id, code);
-        self.register_predicate(traits::Obligation::new(
-            cause,
-            self.param_env,
-            ty::PredicateKind::WellFormed(ty).to_predicate(self.tcx),
-        ));
-    }
-
-    /// Registers an obligation for checking later, during regionck, that the type `ty` must
-    /// outlive the region `r`.
-    pub fn register_wf_const_obligation(
-        &self,
-        ct: &'tcx ty::Const<'tcx>,
+        arg: subst::GenericArg<'tcx>,
         span: Span,
         code: traits::ObligationCauseCode<'tcx>,
     ) {
@@ -3420,28 +3402,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         self.register_predicate(traits::Obligation::new(
             cause,
             self.param_env,
-            ty::PredicateKind::WellFormedConst(ct).to_predicate(self.tcx),
+            ty::PredicateKind::WellFormed(arg).to_predicate(self.tcx),
         ));
     }
 
     /// Registers obligations that all `substs` are well-formed.
     pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr<'_>) {
-        for subst in substs {
-            match subst.unpack() {
-                GenericArgKind::Lifetime(..) => {
-                    // Nothing to do for lifetimes.
-                }
-                GenericArgKind::Type(ty) => {
-                    if !ty.references_error() {
-                        self.register_wf_obligation(ty, expr.span, traits::MiscObligation);
-                    }
-                }
-                GenericArgKind::Const(ct) => {
-                    if !ct.references_error() {
-                        self.register_wf_const_obligation(ct, expr.span, traits::MiscObligation);
-                    }
-                }
-            }
+        for arg in substs.iter().filter(|arg| {
+            matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
+        }) {
+            self.register_wf_obligation(arg, expr.span, traits::MiscObligation);
         }
     }
 
@@ -3872,7 +3842,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 ty::PredicateKind::RegionOutlives(..) => None,
                 ty::PredicateKind::TypeOutlives(..) => None,
                 ty::PredicateKind::WellFormed(..) => None,
-                ty::PredicateKind::WellFormedConst(..) => None,
                 ty::PredicateKind::ObjectSafe(..) => None,
                 ty::PredicateKind::ConstEvaluatable(..) => None,
                 ty::PredicateKind::ConstEquate(..) => None,
@@ -3914,8 +3883,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
 
         // All the input types from the fn signature must outlive the call
         // so as to validate implied bounds.
-        for (fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) {
-            self.register_wf_obligation(fn_input_ty, arg_expr.span, traits::MiscObligation);
+        for (&fn_input_ty, arg_expr) in fn_inputs.iter().zip(args.iter()) {
+            self.register_wf_obligation(fn_input_ty.into(), arg_expr.span, traits::MiscObligation);
         }
 
         let expected_arg_count = fn_inputs.len();
diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs
index e154184f182..7d9bf975c69 100644
--- a/src/librustc_typeck/check/wfcheck.rs
+++ b/src/librustc_typeck/check/wfcheck.rs
@@ -292,7 +292,7 @@ fn check_associated_item(
             ty::AssocKind::Const => {
                 let ty = fcx.tcx.type_of(item.def_id);
                 let ty = fcx.normalize_associated_types_in(span, &ty);
-                fcx.register_wf_obligation(ty, span, code.clone());
+                fcx.register_wf_obligation(ty.into(), span, code.clone());
             }
             ty::AssocKind::Fn => {
                 let sig = fcx.tcx.fn_sig(item.def_id);
@@ -313,7 +313,7 @@ fn check_associated_item(
                 if item.defaultness.has_value() {
                     let ty = fcx.tcx.type_of(item.def_id);
                     let ty = fcx.normalize_associated_types_in(span, &ty);
-                    fcx.register_wf_obligation(ty, span, code.clone());
+                    fcx.register_wf_obligation(ty.into(), span, code.clone());
                 }
             }
             ty::AssocKind::OpaqueTy => {
@@ -406,7 +406,7 @@ fn check_type_defn<'tcx, F>(
             // All field types must be well-formed.
             for field in &variant.fields {
                 fcx.register_wf_obligation(
-                    field.ty,
+                    field.ty.into(),
                     field.span,
                     ObligationCauseCode::MiscObligation,
                 )
@@ -601,7 +601,7 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: hir::HirId, ty_span: Span, allow_fo
             }
         }
 
-        fcx.register_wf_obligation(item_ty, ty_span, ObligationCauseCode::MiscObligation);
+        fcx.register_wf_obligation(item_ty.into(), ty_span, ObligationCauseCode::MiscObligation);
         if forbid_unsized {
             fcx.register_bound(
                 item_ty,
@@ -650,7 +650,7 @@ fn check_impl<'tcx>(
                 let self_ty = fcx.tcx.type_of(item_def_id);
                 let self_ty = fcx.normalize_associated_types_in(item.span, &self_ty);
                 fcx.register_wf_obligation(
-                    self_ty,
+                    self_ty.into(),
                     ast_self_ty.span,
                     ObligationCauseCode::MiscObligation,
                 );
@@ -698,7 +698,7 @@ fn check_where_clauses<'tcx, 'fcx>(
                 // be sure if it will error or not as user might always specify the other.
                 if !ty.needs_subst() {
                     fcx.register_wf_obligation(
-                        ty,
+                        ty.into(),
                         fcx.tcx.def_span(param.def_id),
                         ObligationCauseCode::MiscObligation,
                     );
@@ -841,13 +841,13 @@ fn check_fn_or_method<'fcx, 'tcx>(
     let sig = fcx.normalize_associated_types_in(span, &sig);
     let sig = fcx.tcx.liberate_late_bound_regions(def_id, &sig);
 
-    for (input_ty, span) in sig.inputs().iter().zip(hir_sig.decl.inputs.iter().map(|t| t.span)) {
-        fcx.register_wf_obligation(&input_ty, span, ObligationCauseCode::MiscObligation);
+    for (&input_ty, span) in sig.inputs().iter().zip(hir_sig.decl.inputs.iter().map(|t| t.span)) {
+        fcx.register_wf_obligation(input_ty.into(), span, ObligationCauseCode::MiscObligation);
     }
     implied_bounds.extend(sig.inputs());
 
     fcx.register_wf_obligation(
-        sig.output(),
+        sig.output().into(),
         hir_sig.decl.output.span(),
         ObligationCauseCode::ReturnType,
     );
diff --git a/src/librustc_typeck/impl_wf_check/min_specialization.rs b/src/librustc_typeck/impl_wf_check/min_specialization.rs
index b2e8716b038..e4bffedd620 100644
--- a/src/librustc_typeck/impl_wf_check/min_specialization.rs
+++ b/src/librustc_typeck/impl_wf_check/min_specialization.rs
@@ -332,12 +332,12 @@ fn check_predicates<'tcx>(
         });
 
     // Include the well-formed predicates of the type parameters of the impl.
-    for ty in tcx.impl_trait_ref(impl1_def_id).unwrap().substs.types() {
+    for arg in tcx.impl_trait_ref(impl1_def_id).unwrap().substs {
         if let Some(obligations) = wf::obligations(
             infcx,
             tcx.param_env(impl1_def_id),
             tcx.hir().as_local_hir_id(impl1_def_id),
-            ty,
+            arg,
             span,
         ) {
             impl2_predicates
@@ -405,7 +405,6 @@ fn trait_predicate_kind<'tcx>(
         | ty::PredicateKind::ObjectSafe(_)
         | ty::PredicateKind::ClosureKind(..)
         | ty::PredicateKind::ConstEvaluatable(..)
-        | ty::PredicateKind::ConstEquate(..)
-        | ty::PredicateKind::WellFormedConst(..) => None,
+        | ty::PredicateKind::ConstEquate(..) => None,
     }
 }
diff --git a/src/librustc_typeck/outlives/explicit.rs b/src/librustc_typeck/outlives/explicit.rs
index cf8be687f60..5740cc224cc 100644
--- a/src/librustc_typeck/outlives/explicit.rs
+++ b/src/librustc_typeck/outlives/explicit.rs
@@ -59,8 +59,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
                     | ty::PredicateKind::ClosureKind(..)
                     | ty::PredicateKind::Subtype(..)
                     | ty::PredicateKind::ConstEvaluatable(..)
-                    | ty::PredicateKind::ConstEquate(..)
-                    | ty::PredicateKind::WellFormedConst(..) => (),
+                    | ty::PredicateKind::ConstEquate(..) => (),
                 }
             }
 
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 5c2d6c6453d..371df7444b0 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -491,8 +491,7 @@ impl<'a> Clean<Option<WherePredicate>> for ty::Predicate<'a> {
             | ty::PredicateKind::ObjectSafe(..)
             | ty::PredicateKind::ClosureKind(..)
             | ty::PredicateKind::ConstEvaluatable(..)
-            | ty::PredicateKind::ConstEquate(..)
-            | ty::PredicateKind::WellFormedConst(..) => panic!("not user writable"),
+            | ty::PredicateKind::ConstEquate(..) => panic!("not user writable"),
         }
     }
 }