1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult};
12 use traits::query::Fallible;
13 use ty::{ParamEnvAnd, Predicate, TyCtxt};
15 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
16 pub struct ProvePredicate<'tcx> {
17 pub predicate: Predicate<'tcx>,
20 impl<'tcx> ProvePredicate<'tcx> {
21 pub fn new(predicate: Predicate<'tcx>) -> Self {
22 ProvePredicate { predicate }
26 impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
27 type QueryResult = ();
30 _tcx: TyCtxt<'_, 'gcx, 'tcx>,
31 _key: &ParamEnvAnd<'tcx, Self>,
32 ) -> Option<Self::QueryResult> {
37 tcx: TyCtxt<'_, 'gcx, 'tcx>,
38 canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
39 ) -> Fallible<CanonicalizedQueryResult<'gcx, ()>> {
40 tcx.type_op_prove_predicate(canonicalized)
43 fn shrink_to_tcx_lifetime(
44 v: &'a CanonicalizedQueryResult<'gcx, ()>,
45 ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
50 BraceStructTypeFoldableImpl! {
51 impl<'tcx> TypeFoldable<'tcx> for ProvePredicate<'tcx> {
56 BraceStructLiftImpl! {
57 impl<'a, 'tcx> Lift<'tcx> for ProvePredicate<'a> {
58 type Lifted = ProvePredicate<'tcx>;
63 impl_stable_hash_for! {
64 struct ProvePredicate<'tcx> { predicate }