1 use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
2 use crate::traits::query::Fallible;
3 use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
5 pub use rustc_middle::traits::query::type_op::ProvePredicate;
7 impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
8 type QueryResponse = ();
12 key: &ParamEnvAnd<'tcx, Self>,
13 ) -> Option<Self::QueryResponse> {
14 // Proving Sized, very often on "obviously sized" types like
15 // `&T`, accounts for about 60% percentage of the predicates
16 // we have to prove. No need to canonicalize and all that for
18 if let ty::PredicateKind::Clause(ty::Clause::Trait(trait_ref)) =
19 key.value.predicate.kind().skip_binder()
21 if let Some(sized_def_id) = tcx.lang_items().sized_trait() {
22 if trait_ref.def_id() == sized_def_id {
23 if trait_ref.self_ty().is_trivially_sized(tcx) {
35 mut canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
36 ) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
37 match canonicalized.value.value.predicate.kind().skip_binder() {
38 ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
39 canonicalized.value.param_env.remap_constness_with(pred.constness);
41 _ => canonicalized.value.param_env = canonicalized.value.param_env.without_const(),
43 tcx.type_op_prove_predicate(canonicalized)