Skip to content

Commit b2e899f

Browse files
committed
move into provide methods
1 parent c3f7e02 commit b2e899f

File tree

7 files changed

+73
-29
lines changed

7 files changed

+73
-29
lines changed

src/librustc_traits/dropck_outlives.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@ use rustc::infer::canonical::{Canonical, QueryResult};
1313
use rustc::traits::query::dropck_outlives::{DropckOutlivesResult, DtorckConstraint};
1414
use rustc::traits::query::{CanonicalTyGoal, NoSolution};
1515
use rustc::traits::{FulfillmentContext, Normalized, ObligationCause};
16+
use rustc::ty::query::Providers;
1617
use rustc::ty::subst::{Subst, Substs};
1718
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
1819
use rustc::util::nodemap::FxHashSet;
1920
use rustc_data_structures::sync::Lrc;
2021
use syntax::codemap::{Span, DUMMY_SP};
2122

22-
crate fn dropck_outlives<'tcx>(
23+
crate fn provide(p: &mut Providers) {
24+
*p = Providers {
25+
dropck_outlives,
26+
adt_dtorck_constraint,
27+
..*p
28+
};
29+
}
30+
31+
fn dropck_outlives<'tcx>(
2332
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2433
goal: CanonicalTyGoal<'tcx>,
2534
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, DropckOutlivesResult<'tcx>>>>, NoSolution> {

src/librustc_traits/evaluate_obligation.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@
1111
use rustc::traits::{EvaluationResult, Obligation, ObligationCause,
1212
OverflowError, SelectionContext, TraitQueryMode};
1313
use rustc::traits::query::CanonicalPredicateGoal;
14+
use rustc::ty::query::Providers;
1415
use rustc::ty::{ParamEnvAnd, TyCtxt};
1516
use syntax::codemap::DUMMY_SP;
1617

17-
crate fn evaluate_obligation<'tcx>(
18+
crate fn provide(p: &mut Providers) {
19+
*p = Providers {
20+
evaluate_obligation,
21+
..*p
22+
};
23+
}
24+
25+
fn evaluate_obligation<'tcx>(
1826
tcx: TyCtxt<'_, 'tcx, 'tcx>,
1927
goal: CanonicalPredicateGoal<'tcx>,
2028
) -> Result<EvaluationResult, OverflowError> {

src/librustc_traits/lib.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,10 @@ mod type_op;
3939
use rustc::ty::query::Providers;
4040

4141
pub fn provide(p: &mut Providers) {
42-
*p = Providers {
43-
dropck_outlives: dropck_outlives::dropck_outlives,
44-
adt_dtorck_constraint: dropck_outlives::adt_dtorck_constraint,
45-
normalize_projection_ty: normalize_projection_ty::normalize_projection_ty,
46-
normalize_ty_after_erasing_regions:
47-
normalize_erasing_regions::normalize_ty_after_erasing_regions,
48-
program_clauses_for: lowering::program_clauses_for,
49-
program_clauses_for_env: lowering::program_clauses_for_env,
50-
evaluate_obligation: evaluate_obligation::evaluate_obligation,
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,
58-
..*p
59-
};
42+
dropck_outlives::provide(p);
43+
evaluate_obligation::provide(p);
44+
lowering::provide(p);
45+
normalize_projection_ty::provide(p);
46+
normalize_erasing_regions::provide(p);
47+
type_op::provide(p);
6048
}

src/librustc_traits/lowering.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc::hir::map::definitions::DefPathData;
1414
use rustc::hir::{self, ImplPolarity};
1515
use rustc::traits::{Clause, Clauses, DomainGoal, Goal, PolyDomainGoal, ProgramClause,
1616
WhereClause, FromEnv, WellFormed};
17+
use rustc::ty::query::Providers;
1718
use rustc::ty::subst::Substs;
1819
use rustc::ty::{self, Slice, TyCtxt};
1920
use rustc_data_structures::fx::FxHashSet;
@@ -22,6 +23,14 @@ use syntax::ast;
2223

2324
use std::iter;
2425

26+
crate fn provide(p: &mut Providers) {
27+
*p = Providers {
28+
program_clauses_for,
29+
program_clauses_for_env,
30+
..*p
31+
};
32+
}
33+
2534
crate trait Lower<T> {
2635
/// Lower a rustc construct (e.g. `ty::TraitPredicate`) to a chalk-like type.
2736
fn lower(&self) -> T;

src/librustc_traits/normalize_erasing_regions.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010

1111
use rustc::traits::{Normalized, ObligationCause};
1212
use rustc::traits::query::NoSolution;
13+
use rustc::ty::query::Providers;
1314
use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
1415
use std::sync::atomic::Ordering;
1516

16-
crate fn normalize_ty_after_erasing_regions<'tcx>(
17+
crate fn provide(p: &mut Providers) {
18+
*p = Providers {
19+
normalize_ty_after_erasing_regions,
20+
..*p
21+
};
22+
}
23+
24+
fn normalize_ty_after_erasing_regions<'tcx>(
1725
tcx: TyCtxt<'_, 'tcx, 'tcx>,
1826
goal: ParamEnvAnd<'tcx, Ty<'tcx>>,
1927
) -> Ty<'tcx> {

src/librustc_traits/normalize_projection_ty.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@ use rustc::infer::canonical::{Canonical, QueryResult};
1212
use rustc::infer::InferOk;
1313
use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution};
1414
use rustc::traits::{self, ObligationCause, SelectionContext};
15+
use rustc::ty::query::Providers;
1516
use rustc::ty::{ParamEnvAnd, TyCtxt};
1617
use rustc_data_structures::sync::Lrc;
1718
use std::sync::atomic::Ordering;
1819
use syntax::ast::DUMMY_NODE_ID;
1920
use syntax_pos::DUMMY_SP;
2021

21-
crate fn normalize_projection_ty<'tcx>(
22+
crate fn provide(p: &mut Providers) {
23+
*p = Providers {
24+
normalize_projection_ty,
25+
..*p
26+
};
27+
}
28+
29+
fn normalize_projection_ty<'tcx>(
2230
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2331
goal: CanonicalProjectionGoal<'tcx>,
2432
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {

src/librustc_traits/type_op.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,25 @@ use rustc::traits::query::type_op::prove_predicate::ProvePredicate;
1616
use rustc::traits::query::type_op::subtype::Subtype;
1717
use rustc::traits::query::{Fallible, NoSolution};
1818
use rustc::traits::{Obligation, Normalized, ObligationCause};
19+
use rustc::ty::query::Providers;
1920
use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
2021
use rustc_data_structures::sync::Lrc;
2122
use std::fmt;
2223

23-
crate fn type_op_eq<'tcx>(
24+
crate fn provide(p: &mut Providers) {
25+
*p = Providers {
26+
type_op_eq,
27+
type_op_prove_predicate,
28+
type_op_subtype,
29+
type_op_normalize_ty,
30+
type_op_normalize_predicate,
31+
type_op_normalize_fn_sig,
32+
type_op_normalize_poly_fn_sig,
33+
..*p
34+
};
35+
}
36+
37+
fn type_op_eq<'tcx>(
2438
tcx: TyCtxt<'_, 'tcx, 'tcx>,
2539
canonicalized: Canonical<'tcx, Eq<'tcx>>,
2640
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
@@ -44,39 +58,39 @@ where
4458
Ok(InferOk { value, obligations }) // ugh we should merge these two structs
4559
}
4660

47-
crate fn type_op_normalize_ty(
61+
fn type_op_normalize_ty(
4862
tcx: TyCtxt<'_, 'tcx, 'tcx>,
4963
canonicalized: Canonical<'tcx, Normalize<'tcx, Ty<'tcx>>>,
5064
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Ty<'tcx>>>>, NoSolution> {
5165
tcx.infer_ctxt()
5266
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
5367
}
5468

55-
crate fn type_op_normalize_predicate(
69+
fn type_op_normalize_predicate(
5670
tcx: TyCtxt<'_, 'tcx, 'tcx>,
5771
canonicalized: Canonical<'tcx, Normalize<'tcx, Predicate<'tcx>>>,
5872
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Predicate<'tcx>>>>, NoSolution> {
5973
tcx.infer_ctxt()
6074
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
6175
}
6276

63-
crate fn type_op_normalize_fn_sig(
77+
fn type_op_normalize_fn_sig(
6478
tcx: TyCtxt<'_, 'tcx, 'tcx>,
6579
canonicalized: Canonical<'tcx, Normalize<'tcx, FnSig<'tcx>>>,
6680
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, FnSig<'tcx>>>>, NoSolution> {
6781
tcx.infer_ctxt()
6882
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
6983
}
7084

71-
crate fn type_op_normalize_poly_fn_sig(
85+
fn type_op_normalize_poly_fn_sig(
7286
tcx: TyCtxt<'_, 'tcx, 'tcx>,
7387
canonicalized: Canonical<'tcx, Normalize<'tcx, PolyFnSig<'tcx>>>,
7488
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
7589
tcx.infer_ctxt()
7690
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
7791
}
7892

79-
crate fn type_op_subtype<'tcx>(
93+
fn type_op_subtype<'tcx>(
8094
tcx: TyCtxt<'_, 'tcx, 'tcx>,
8195
canonicalized: Canonical<'tcx, Subtype<'tcx>>,
8296
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
@@ -95,7 +109,7 @@ crate fn type_op_subtype<'tcx>(
95109
)
96110
}
97111

98-
crate fn type_op_prove_predicate<'tcx>(
112+
fn type_op_prove_predicate<'tcx>(
99113
tcx: TyCtxt<'_, 'tcx, 'tcx>,
100114
canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
101115
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {

0 commit comments

Comments
 (0)