Skip to content

Commit d49d522

Browse files
committed
merge all the type_op_foo modules into one as they are so trivial
1 parent 66c8839 commit d49d522

File tree

5 files changed

+62
-111
lines changed

5 files changed

+62
-111
lines changed

src/librustc_traits/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ mod evaluate_obligation;
3434
mod normalize_projection_ty;
3535
mod normalize_erasing_regions;
3636
pub mod lowering;
37-
mod type_op_eq;
38-
mod type_op_normalize;
39-
mod type_op_prove_predicate;
40-
mod type_op_subtype;
37+
mod type_op;
4138

4239
use rustc::ty::query::Providers;
4340

@@ -51,13 +48,13 @@ pub fn provide(p: &mut Providers) {
5148
program_clauses_for: lowering::program_clauses_for,
5249
program_clauses_for_env: lowering::program_clauses_for_env,
5350
evaluate_obligation: evaluate_obligation::evaluate_obligation,
54-
type_op_eq: type_op_eq::type_op_eq,
55-
type_op_prove_predicate: type_op_prove_predicate::type_op_prove_predicate,
56-
type_op_subtype: type_op_subtype::type_op_subtype,
57-
type_op_normalize_ty: type_op_normalize::type_op_normalize_ty,
58-
type_op_normalize_predicate: type_op_normalize::type_op_normalize_predicate,
59-
type_op_normalize_fn_sig: type_op_normalize::type_op_normalize_fn_sig,
60-
type_op_normalize_poly_fn_sig: type_op_normalize::type_op_normalize_poly_fn_sig,
51+
type_op_eq: type_op::type_op_eq,
52+
type_op_prove_predicate: type_op::type_op_prove_predicate,
53+
type_op_subtype: type_op::type_op_subtype,
54+
type_op_normalize_ty: type_op::type_op_normalize_ty,
55+
type_op_normalize_predicate: type_op::type_op_normalize_predicate,
56+
type_op_normalize_fn_sig: type_op::type_op_normalize_fn_sig,
57+
type_op_normalize_poly_fn_sig: type_op::type_op_normalize_poly_fn_sig,
6158
..*p
6259
};
6360
}

src/librustc_traits/type_op_normalize.rs renamed to src/librustc_traits/type_op.rs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,26 @@
1010

1111
use rustc::infer::canonical::{Canonical, QueryResult};
1212
use rustc::infer::{InferCtxt, InferOk};
13+
use rustc::traits::query::type_op::eq::Eq;
1314
use rustc::traits::query::type_op::normalize::Normalize;
15+
use rustc::traits::query::type_op::prove_predicate::ProvePredicate;
16+
use rustc::traits::query::type_op::subtype::Subtype;
1417
use rustc::traits::query::{Fallible, NoSolution};
15-
use rustc::traits::{Normalized, ObligationCause};
18+
use rustc::traits::{Obligation, Normalized, ObligationCause};
1619
use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
1720
use rustc_data_structures::sync::Lrc;
1821
use std::fmt;
1922

23+
crate fn type_op_eq<'tcx>(
24+
tcx: TyCtxt<'_, 'tcx, 'tcx>,
25+
canonicalized: Canonical<'tcx, Eq<'tcx>>,
26+
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
27+
tcx.infer_ctxt()
28+
.enter_canonical_trait_query(&canonicalized, |infcx, Eq { param_env, a, b }| {
29+
Ok(infcx.at(&ObligationCause::dummy(), param_env).eq(a, b)?)
30+
})
31+
}
32+
2033
fn type_op_normalize<T>(
2134
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
2235
key: Normalize<'tcx, T>,
@@ -62,3 +75,43 @@ crate fn type_op_normalize_poly_fn_sig(
6275
tcx.infer_ctxt()
6376
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
6477
}
78+
79+
crate fn type_op_subtype<'tcx>(
80+
tcx: TyCtxt<'_, 'tcx, 'tcx>,
81+
canonicalized: Canonical<'tcx, Subtype<'tcx>>,
82+
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
83+
tcx.infer_ctxt().enter_canonical_trait_query(
84+
&canonicalized,
85+
|infcx,
86+
Subtype {
87+
param_env,
88+
sub,
89+
sup,
90+
}| {
91+
Ok(infcx
92+
.at(&ObligationCause::dummy(), param_env)
93+
.sup(sup, sub)?)
94+
},
95+
)
96+
}
97+
98+
crate fn type_op_prove_predicate<'tcx>(
99+
tcx: TyCtxt<'_, 'tcx, 'tcx>,
100+
canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
101+
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
102+
tcx.infer_ctxt()
103+
.enter_canonical_trait_query(&canonicalized, |_infcx, key| {
104+
let ProvePredicate {
105+
param_env,
106+
predicate,
107+
} = key;
108+
Ok(InferOk {
109+
value: (),
110+
obligations: vec![Obligation::new(
111+
ObligationCause::dummy(),
112+
param_env,
113+
predicate,
114+
)],
115+
})
116+
})
117+
}

src/librustc_traits/type_op_eq.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/librustc_traits/type_op_prove_predicate.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/librustc_traits/type_op_subtype.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)