]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_lint/builtin.rs
introduce PredicateAtom
[rust.git] / src / librustc_lint / builtin.rs
index cedf742b9a9498558a915701709545a156d9c302..d67be44e4f0c5d97d3ca7abd2af8ef99ba63baec 100644 (file)
@@ -1202,7 +1202,7 @@ 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);
@@ -1210,7 +1210,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
             for &(predicate, span) in predicates.predicates {
                 // We don't actually look inside of the predicate,
                 // so it is safe to skip this binder here.
-                let predicate_kind_name = match predicate.ignore_qualifiers(cx.tcx).skip_binder().kind() {
+                let predicate_kind_name = match predicate.skip_binders() {
                     Trait(..) => "Trait",
                     TypeOutlives(..) |
                     RegionOutlives(..) => "Lifetime",
@@ -1225,7 +1225,6 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) {
                     Subtype(..) |
                     ConstEvaluatable(..) |
                     ConstEquate(..) => continue,
-                    ForAll(_) => bug!("unexpected predicate: {:?}", predicate)
                 };
                 if predicate.is_global() {
                     cx.struct_span_lint(TRIVIAL_BOUNDS, span, |lint| {
@@ -1495,14 +1494,13 @@ fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: Ident) {
 
 impl ExplicitOutlivesRequirements {
     fn lifetimes_outliving_lifetime<'tcx>(
-        tcx: TyCtxt<'tcx>,
         inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
         index: u32,
     ) -> Vec<ty::Region<'tcx>> {
         inferred_outlives
             .iter()
-            .filter_map(|(pred, _)| match pred.ignore_qualifiers(tcx).skip_binder().kind() {
-                &ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match a {
+            .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,
                 },
@@ -1512,14 +1510,13 @@ fn lifetimes_outliving_lifetime<'tcx>(
     }
 
     fn lifetimes_outliving_type<'tcx>(
-        tcx: TyCtxt<'tcx>,
         inferred_outlives: &'tcx [(ty::Predicate<'tcx>, Span)],
         index: u32,
     ) -> Vec<ty::Region<'tcx>> {
         inferred_outlives
             .iter()
-            .filter_map(|(pred, _)| match pred.ignore_qualifiers(tcx).skip_binder().kind() {
-                &ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
+            .filter_map(|(pred, _)| match pred.skip_binders() {
+                ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(a, b)) => {
                     a.is_param(index).then_some(b)
                 }
                 _ => None,
@@ -1539,10 +1536,10 @@ fn collect_outlived_lifetimes<'tcx>(
 
         match param.kind {
             hir::GenericParamKind::Lifetime { .. } => {
-                Self::lifetimes_outliving_lifetime(tcx, inferred_outlives, index)
+                Self::lifetimes_outliving_lifetime(inferred_outlives, index)
             }
             hir::GenericParamKind::Type { .. } => {
-                Self::lifetimes_outliving_type(tcx, inferred_outlives, index)
+                Self::lifetimes_outliving_type(inferred_outlives, index)
             }
             hir::GenericParamKind::Const { .. } => Vec::new(),
         }
@@ -1694,11 +1691,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
                             cx.tcx.named_region(predicate.lifetime.hir_id)
                         {
                             (
-                                Self::lifetimes_outliving_lifetime(
-                                    cx.tcx,
-                                    inferred_outlives,
-                                    index,
-                                ),
+                                Self::lifetimes_outliving_lifetime(inferred_outlives, index),
                                 &predicate.bounds,
                                 predicate.span,
                             )
@@ -1714,11 +1707,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
                                 if let Res::Def(DefKind::TyParam, def_id) = path.res {
                                     let index = ty_generics.param_def_id_to_index[&def_id];
                                     (
-                                        Self::lifetimes_outliving_type(
-                                            cx.tcx,
-                                            inferred_outlives,
-                                            index,
-                                        ),
+                                        Self::lifetimes_outliving_type(inferred_outlives, index),
                                         &predicate.bounds,
                                         predicate.span,
                                     )