about summary refs log tree commit diff
path: root/compiler/rustc_infer/src/traits
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2021-12-12 12:34:46 +0800
committerDeadbeef <ent3rm4n@gmail.com>2021-12-12 12:34:46 +0800
commit84b1d859c8caa6049bfe728b219f679286151bb2 (patch)
tree472c311c437160a1bc2dd88d43d134e735e4a94b /compiler/rustc_infer/src/traits
parentc5f8788d8d3c158173450e21fe17c4034819816d (diff)
downloadrust-84b1d859c8caa6049bfe728b219f679286151bb2.tar.gz
rust-84b1d859c8caa6049bfe728b219f679286151bb2.zip
Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing
changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
Diffstat (limited to 'compiler/rustc_infer/src/traits')
-rw-r--r--compiler/rustc_infer/src/traits/engine.rs20
-rw-r--r--compiler/rustc_infer/src/traits/mod.rs10
-rw-r--r--compiler/rustc_infer/src/traits/util.rs10
3 files changed, 16 insertions, 24 deletions
diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs
index 152a395c871..822f2365e02 100644
--- a/compiler/rustc_infer/src/traits/engine.rs
+++ b/compiler/rustc_infer/src/traits/engine.rs
@@ -1,9 +1,8 @@
 use crate::infer::InferCtxt;
 use crate::traits::Obligation;
 use rustc_data_structures::fx::FxHashMap;
-use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
-use rustc_middle::ty::{self, ToPredicate, Ty, WithConstness};
+use rustc_middle::ty::{self, ToPredicate, Ty};
 
 use super::FulfillmentError;
 use super::{ObligationCause, PredicateObligation};
@@ -48,26 +47,9 @@ pub trait TraitEngine<'tcx>: 'tcx {
 
     fn select_all_or_error(&mut self, infcx: &InferCtxt<'_, 'tcx>) -> Vec<FulfillmentError<'tcx>>;
 
-    fn select_all_with_constness_or_error(
-        &mut self,
-        infcx: &InferCtxt<'_, 'tcx>,
-        _constness: hir::Constness,
-    ) -> Vec<FulfillmentError<'tcx>> {
-        self.select_all_or_error(infcx)
-    }
-
     fn select_where_possible(&mut self, infcx: &InferCtxt<'_, 'tcx>)
     -> Vec<FulfillmentError<'tcx>>;
 
-    // FIXME(fee1-dead) this should not provide a default body for chalk as chalk should be updated
-    fn select_with_constness_where_possible(
-        &mut self,
-        infcx: &InferCtxt<'_, 'tcx>,
-        _constness: hir::Constness,
-    ) -> Vec<FulfillmentError<'tcx>> {
-        self.select_where_possible(infcx)
-    }
-
     fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
 
     fn relationships(&mut self) -> &mut FxHashMap<ty::TyVid, ty::FoundRelationships>;
diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs
index e8622b3c819..7e30f859dae 100644
--- a/compiler/rustc_infer/src/traits/mod.rs
+++ b/compiler/rustc_infer/src/traits/mod.rs
@@ -69,6 +69,16 @@ impl PredicateObligation<'tcx> {
     }
 }
 
+impl TraitObligation<'tcx> {
+    /// Returns `true` if the trait predicate is considered `const` in its ParamEnv.
+    pub fn is_const(&self) -> bool {
+        match (self.predicate.skip_binder().constness, self.param_env.constness()) {
+            (ty::BoundConstness::ConstIfConst, hir::Constness::Const) => true,
+            _ => false,
+        }
+    }
+}
+
 // `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
 #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
 static_assert_size!(PredicateObligation<'_>, 32);
diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs
index 92f74af4eb3..61588147364 100644
--- a/compiler/rustc_infer/src/traits/util.rs
+++ b/compiler/rustc_infer/src/traits/util.rs
@@ -3,7 +3,7 @@ use smallvec::smallvec;
 use crate::infer::outlives::components::{push_outlives_components, Component};
 use crate::traits::{Obligation, ObligationCause, PredicateObligation};
 use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
-use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness};
+use rustc_middle::ty::{self, ToPredicate, TyCtxt};
 use rustc_span::symbol::Ident;
 use rustc_span::Span;
 
@@ -328,8 +328,8 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
                 ));
                 for (super_predicate, _) in super_predicates.predicates {
                     let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
-                    if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() {
-                        stack.push(binder.value);
+                    if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {
+                        stack.push(binder.map_bound(|t| t.trait_ref));
                     }
                 }
 
@@ -362,8 +362,8 @@ impl<'tcx, I: Iterator<Item = PredicateObligation<'tcx>>> Iterator for FilterToT
 
     fn next(&mut self) -> Option<ty::PolyTraitRef<'tcx>> {
         while let Some(obligation) = self.base_iterator.next() {
-            if let Some(data) = obligation.predicate.to_opt_poly_trait_ref() {
-                return Some(data.value);
+            if let Some(data) = obligation.predicate.to_opt_poly_trait_pred() {
+                return Some(data.map_bound(|t| t.trait_ref));
             }
         }
         None