Skip to content

Commit 2655522

Browse files
committed
move type_op into rustc
1 parent 3b446b4 commit 2655522

File tree

11 files changed

+61
-65
lines changed

11 files changed

+61
-65
lines changed

src/librustc/traits/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub mod dropck_outlives;
2222
pub mod evaluate_obligation;
2323
pub mod normalize;
2424
pub mod normalize_erasing_regions;
25+
pub mod type_op;
2526

2627
pub type CanonicalProjectionGoal<'tcx> =
2728
Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::ProjectionTy<'tcx>>>;

src/librustc_mir/borrow_check/nll/type_check/type_op/custom.rs renamed to src/librustc/traits/query/type_op/custom.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::{InferCtxt, InferResult};
12-
use rustc::ty::TyCtxt;
11+
use infer::{InferCtxt, InferResult};
12+
use ty::TyCtxt;
1313
use std::fmt;
1414

15-
crate struct CustomTypeOp<F, G> {
15+
pub struct CustomTypeOp<F, G> {
1616
closure: F,
1717
description: G,
1818
}
1919

2020
impl<F, G> CustomTypeOp<F, G> {
21-
crate fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self
21+
pub fn new<'gcx, 'tcx, R>(closure: F, description: G) -> Self
2222
where
2323
F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, R>,
2424
G: Fn() -> String,
@@ -32,7 +32,7 @@ impl<F, G> CustomTypeOp<F, G> {
3232

3333
impl<'gcx, 'tcx, F, R, G> super::TypeOp<'gcx, 'tcx> for CustomTypeOp<F, G>
3434
where
35-
F: FnOnce(&InferCtxt<'_, 'gcx, 'tcx>) -> InferResult<'tcx, R>,
35+
F: for<'a, 'cx> FnOnce(&'a InferCtxt<'cx, 'gcx, 'tcx>) -> InferResult<'tcx, R>,
3636
G: Fn() -> String,
3737
{
3838
type Output = R;

src/librustc_mir/borrow_check/nll/type_check/type_op/eq.rs renamed to src/librustc/traits/query/type_op/eq.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::canonical::{CanonicalizedQueryResult, Canonical};
12-
use rustc::traits::query::NoSolution;
13-
use rustc::traits::{FulfillmentContext, ObligationCause};
14-
use rustc::ty::{self, ParamEnv, Ty, TyCtxt};
11+
use infer::canonical::{CanonicalizedQueryResult, Canonical};
12+
use traits::query::NoSolution;
13+
use traits::{FulfillmentContext, ObligationCause};
14+
use ty::{self, ParamEnv, Ty, TyCtxt};
1515
use syntax::codemap::DUMMY_SP;
1616

1717
#[derive(Copy, Clone, Debug)]
18-
crate struct Eq<'tcx> {
18+
pub struct Eq<'tcx> {
1919
param_env: ParamEnv<'tcx>,
2020
a: Ty<'tcx>,
2121
b: Ty<'tcx>,
2222
}
2323

2424
impl<'tcx> Eq<'tcx> {
25-
crate fn new(param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> Self {
25+
pub fn new(param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> Self {
2626
Self { param_env, a, b }
2727
}
2828
}

src/librustc_mir/borrow_check/nll/type_check/type_op/mod.rs renamed to src/librustc/traits/query/type_op/mod.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::canonical::query_result;
12-
use rustc::infer::canonical::{Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint};
13-
use rustc::infer::{InferCtxt, InferOk, InferResult};
14-
use rustc::traits::{ObligationCause, TraitEngine};
15-
use rustc::ty::error::TypeError;
16-
use rustc::ty::fold::TypeFoldable;
17-
use rustc::ty::{Lift, ParamEnv, TyCtxt};
11+
use infer::canonical::query_result;
12+
use infer::canonical::{Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint};
13+
use infer::{InferCtxt, InferOk, InferResult};
14+
use traits::{ObligationCause, TraitEngine};
15+
use ty::error::TypeError;
16+
use ty::fold::TypeFoldable;
17+
use ty::{Lift, ParamEnv, TyCtxt};
1818
use std::fmt;
1919
use std::rc::Rc;
2020
use syntax::codemap::DUMMY_SP;
2121

22-
crate mod custom;
23-
crate mod eq;
24-
crate mod normalize;
25-
crate mod outlives;
26-
crate mod predicates;
27-
crate mod subtype;
22+
pub mod custom;
23+
pub mod eq;
24+
pub mod normalize;
25+
pub mod outlives;
26+
pub mod predicates;
27+
pub mod subtype;
2828

29-
crate trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
29+
pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
3030
type Output;
3131

3232
/// Micro-optimization: returns `Ok(x)` if we can trivially
@@ -100,7 +100,7 @@ crate trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
100100

101101
type Lifted<'gcx, T> = <T as Lift<'gcx>>::Lifted;
102102

103-
crate trait QueryTypeOp<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> {
103+
pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> {
104104
type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>;
105105

106106
/// Micro-optimization: returns `Ok(x)` if we can trivially

src/librustc_mir/borrow_check/nll/type_check/type_op/normalize.rs renamed to src/librustc/traits/query/type_op/normalize.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::{InferCtxt, InferOk, InferResult};
12-
use rustc::traits::query::NoSolution;
13-
use rustc::traits::{Normalized, ObligationCause};
14-
use rustc::ty::fold::TypeFoldable;
15-
use rustc::ty::{ParamEnv, TyCtxt};
11+
use infer::{InferCtxt, InferOk, InferResult};
12+
use traits::query::NoSolution;
13+
use traits::{Normalized, ObligationCause};
14+
use ty::fold::TypeFoldable;
15+
use ty::{ParamEnv, TyCtxt};
1616
use std::fmt;
1717

1818
#[derive(Debug)]
19-
crate struct Normalize<'tcx, T> {
19+
pub struct Normalize<'tcx, T> {
2020
param_env: ParamEnv<'tcx>,
2121
value: T,
2222
}
@@ -25,7 +25,7 @@ impl<'tcx, T> Normalize<'tcx, T>
2525
where
2626
T: fmt::Debug + TypeFoldable<'tcx>,
2727
{
28-
crate fn new(param_env: ParamEnv<'tcx>, value: T) -> Self {
28+
pub fn new(param_env: ParamEnv<'tcx>, value: T) -> Self {
2929
Self { param_env, value }
3030
}
3131
}

src/librustc_mir/borrow_check/nll/type_check/type_op/outlives.rs renamed to src/librustc/traits/query/type_op/outlives.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::{InferCtxt, InferResult};
12-
use rustc::traits::query::dropck_outlives::trivial_dropck_outlives;
13-
use rustc::traits::ObligationCause;
14-
use rustc::ty::subst::Kind;
15-
use rustc::ty::{ParamEnv, Ty, TyCtxt};
11+
use infer::{InferCtxt, InferResult};
12+
use traits::query::dropck_outlives::trivial_dropck_outlives;
13+
use traits::ObligationCause;
14+
use ty::subst::Kind;
15+
use ty::{ParamEnv, Ty, TyCtxt};
1616

1717
#[derive(Debug)]
18-
crate struct DropckOutlives<'tcx> {
18+
pub struct DropckOutlives<'tcx> {
1919
param_env: ParamEnv<'tcx>,
2020
dropped_ty: Ty<'tcx>,
2121
}
2222

2323
impl<'tcx> DropckOutlives<'tcx> {
24-
crate fn new(param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>) -> Self {
24+
pub fn new(param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>) -> Self {
2525
DropckOutlives {
2626
param_env,
2727
dropped_ty,

src/librustc_mir/borrow_check/nll/type_check/type_op/predicates.rs renamed to src/librustc/traits/query/type_op/predicates.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::{InferCtxt, InferOk, InferResult};
12-
use rustc::traits::{Obligation, ObligationCause, PredicateObligation};
13-
use rustc::ty::{ParamEnv, Predicate, TyCtxt};
11+
use infer::{InferCtxt, InferOk, InferResult};
12+
use traits::{Obligation, ObligationCause, PredicateObligation};
13+
use ty::{ParamEnv, Predicate, TyCtxt};
1414

1515
#[derive(Debug)]
16-
crate struct ProvePredicates<'tcx> {
16+
pub struct ProvePredicates<'tcx> {
1717
obligations: Vec<PredicateObligation<'tcx>>,
1818
}
1919

2020
impl<'tcx> ProvePredicates<'tcx> {
21-
crate fn new(
21+
pub fn new(
2222
param_env: ParamEnv<'tcx>,
2323
predicates: impl IntoIterator<Item = Predicate<'tcx>>,
2424
) -> Self {

src/librustc_mir/borrow_check/nll/type_check/type_op/subtype.rs renamed to src/librustc/traits/query/type_op/subtype.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::infer::{InferCtxt, InferResult};
12-
use rustc::traits::ObligationCause;
13-
use rustc::ty::{ParamEnv, Ty, TyCtxt};
11+
use infer::{InferCtxt, InferResult};
12+
use traits::ObligationCause;
13+
use ty::{ParamEnv, Ty, TyCtxt};
1414

1515
#[derive(Debug)]
16-
crate struct Subtype<'tcx> {
16+
pub struct Subtype<'tcx> {
1717
param_env: ParamEnv<'tcx>,
1818
sub: Ty<'tcx>,
1919
sup: Ty<'tcx>,
2020
}
2121

2222
impl<'tcx> Subtype<'tcx> {
23-
crate fn new(param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
23+
pub fn new(param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
2424
Self {
2525
param_env,
2626
sub,

src/librustc_mir/borrow_check/nll/type_check/input_output.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
//! contain revealed `impl Trait` values).
1919
2020
use borrow_check::nll::renumber;
21-
use borrow_check::nll::type_check::type_op::custom::CustomTypeOp;
2221
use borrow_check::nll::universal_regions::UniversalRegions;
2322
use rustc::hir::def_id::DefId;
2423
use rustc::infer::InferOk;
2524
use rustc::mir::visit::TyContext;
2625
use rustc::mir::*;
26+
use rustc::traits::query::type_op::custom::CustomTypeOp;
2727
use rustc::traits::{ObligationCause, PredicateObligations};
2828
use rustc::ty::subst::Subst;
2929
use rustc::ty::Ty;

src/librustc_mir/borrow_check/nll/type_check/liveness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
// except according to those terms.
1010

1111
use borrow_check::nll::region_infer::Cause;
12-
use borrow_check::nll::type_check::type_op::TypeOp;
13-
use borrow_check::nll::type_check::type_op::outlives::DropckOutlives;
1412
use borrow_check::nll::type_check::AtLocation;
1513
use dataflow::move_paths::{HasMoveData, MoveData};
1614
use dataflow::MaybeInitializedPlaces;
1715
use dataflow::{FlowAtLocation, FlowsAtLocation};
1816
use rustc::infer::canonical::QueryRegionConstraint;
1917
use rustc::mir::Local;
2018
use rustc::mir::{BasicBlock, Location, Mir};
19+
use rustc::traits::query::type_op::outlives::DropckOutlives;
20+
use rustc::traits::query::type_op::TypeOp;
2121
use rustc::ty::subst::Kind;
2222
use rustc::ty::{Ty, TypeFoldable};
2323
use rustc_data_structures::fx::FxHashMap;

src/librustc_mir/borrow_check/nll/type_check/mod.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
2727
use rustc::mir::tcx::PlaceTy;
2828
use rustc::mir::visit::{PlaceContext, Visitor};
2929
use rustc::mir::*;
30+
use rustc::traits::query::type_op;
3031
use rustc::traits::ObligationCause;
3132
use rustc::ty::error::TypeError;
3233
use rustc::ty::fold::TypeFoldable;
@@ -66,7 +67,6 @@ macro_rules! span_mirbug_and_err {
6667
mod constraint_conversion;
6768
mod input_output;
6869
mod liveness;
69-
mod type_op;
7070

7171
/// Type checks the given `mir` in the context of the inference
7272
/// context `infcx`. Returns any region constraints that have yet to
@@ -776,7 +776,10 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
776776
locations: Locations,
777777
) -> UnitResult<'tcx> {
778778
let param_env = self.param_env;
779-
self.fully_perform_op(locations, type_op::subtype::Subtype::new(param_env, sub, sup))
779+
self.fully_perform_op(
780+
locations,
781+
type_op::subtype::Subtype::new(param_env, sub, sup),
782+
)
780783
}
781784

782785
fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> UnitResult<'tcx> {
@@ -1623,16 +1626,8 @@ impl MirPass for TypeckMir {
16231626
}
16241627
let param_env = tcx.param_env(def_id);
16251628
tcx.infer_ctxt().enter(|infcx| {
1626-
let _ = type_check_internal(
1627-
&infcx,
1628-
def_id,
1629-
param_env,
1630-
mir,
1631-
&[],
1632-
None,
1633-
None,
1634-
&mut |_| (),
1635-
);
1629+
let _ =
1630+
type_check_internal(&infcx, def_id, param_env, mir, &[], None, None, &mut |_| ());
16361631

16371632
// For verification purposes, we just ignore the resulting
16381633
// region constraint sets. Not our problem. =)

0 commit comments

Comments
 (0)