]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_lint/builtin.rs
introduce PredicateAtom
[rust.git] / src / librustc_lint / builtin.rs
index 5c4be715add79de0552f88b8f82909b74865fdeb..d67be44e4f0c5d97d3ca7abd2af8ef99ba63baec 100644 (file)
@@ -1202,13 +1202,15 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
 impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
     fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
         use rustc_middle::ty::fold::TypeFoldable;
-        use rustc_middle::ty::PredicateKind::*;
+        use rustc_middle::ty::PredicateAtom::*;
 
         if cx.tcx.features().trivial_bounds {
             let def_id = cx.tcx.hir().local_def_id(item.hir_id);
             let predicates = cx.tcx.predicates_of(def_id);
             for &(predicate, span) in predicates.predicates {
-                let predicate_kind_name = match predicate.kind() {
+                // We don't actually look inside of the predicate,
+                // so it is safe to skip this binder here.
+                let predicate_kind_name = match predicate.skip_binders() {
                     Trait(..) => "Trait",
                     TypeOutlives(..) |
                     RegionOutlives(..) => "Lifetime",
@@ -1497,14 +1499,11 @@ fn lifetimes_outliving_lifetime<'tcx>(
     ) -> Vec<ty::Region<'tcx>> {
         inferred_outlives
             .iter()
-            .filter_map(|(pred, _)| match pred.kind() {
-                ty::PredicateKind::RegionOutlives(outlives) => {
-                    let outlives = outlives.skip_binder();
-                    match outlives.0 {
-                        ty::ReEarlyBound(ebr) if ebr.index == index => Some(outlives.1),
-                        _ => None,
-                    }
-                }
+            .filter_map(|(pred, _)| match pred.skip_binders() {
+                ty::PredicateAtom::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
+                    ty::ReEarlyBound(ebr) if ebr.index == index => Some(b),
+                    _ => None,
+                },
                 _ => None,
             })
             .collect()
@@ -1516,10 +1515,9 @@ fn lifetimes_outliving_type<'tcx>(
     ) -> Vec<ty::Region<'tcx>> {
         inferred_outlives
             .iter()
-            .filter_map(|(pred, _)| match pred.kind() {
-                ty::PredicateKind::TypeOutlives(outlives) => {
-                    let outlives = outlives.skip_binder();
-                    outlives.0.is_param(index).then_some(outlives.1)
+            .filter_map(|(pred, _)| match pred.skip_binders() {
+                ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
+                    a.is_param(index).then_some(b)
                 }
                 _ => None,
             })