]> git.lizzy.rs Git - rust.git/blob - src/librustc/traits/query/type_op/prove_predicate.rs
Rollup merge of #51765 - jonas-schievink:patch-1, r=KodrAus
[rust.git] / src / librustc / traits / query / type_op / prove_predicate.rs
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.
4 //
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.
10
11 use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult};
12 use traits::query::Fallible;
13 use ty::{ParamEnvAnd, Predicate, TyCtxt};
14
15 #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
16 pub struct ProvePredicate<'tcx> {
17     pub predicate: Predicate<'tcx>,
18 }
19
20 impl<'tcx> ProvePredicate<'tcx> {
21     pub fn new(predicate: Predicate<'tcx>) -> Self {
22         ProvePredicate { predicate }
23     }
24 }
25
26 impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
27     type QueryResult = ();
28
29     fn try_fast_path(
30         _tcx: TyCtxt<'_, 'gcx, 'tcx>,
31         _key: &ParamEnvAnd<'tcx, Self>,
32     ) -> Option<Self::QueryResult> {
33         None
34     }
35
36     fn perform_query(
37         tcx: TyCtxt<'_, 'gcx, 'tcx>,
38         canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
39     ) -> Fallible<CanonicalizedQueryResult<'gcx, ()>> {
40         tcx.type_op_prove_predicate(canonicalized)
41     }
42
43     fn shrink_to_tcx_lifetime(
44         v: &'a CanonicalizedQueryResult<'gcx, ()>,
45     ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
46         v
47     }
48 }
49
50 BraceStructTypeFoldableImpl! {
51     impl<'tcx> TypeFoldable<'tcx> for ProvePredicate<'tcx> {
52         predicate,
53     }
54 }
55
56 BraceStructLiftImpl! {
57     impl<'a, 'tcx> Lift<'tcx> for ProvePredicate<'a> {
58         type Lifted = ProvePredicate<'tcx>;
59         predicate,
60     }
61 }
62
63 impl_stable_hash_for! {
64     struct ProvePredicate<'tcx> { predicate }
65 }