Skip to content

Commit 7c44561

Browse files
committed
Move various data structures out of typeck and into ty.
1 parent 6d965cc commit 7c44561

29 files changed

+331
-344
lines changed

src/librustc/lint/builtin.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use metadata::csearch;
3030
use middle::def::*;
3131
use middle::ty::{mod, Ty};
3232
use middle::typeck::astconv::ast_ty_to_ty;
33-
use middle::typeck::{mod, infer};
33+
use middle::typeck::infer;
3434
use middle::{def, pat_util, stability};
3535
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
3636
use util::ppaux::{ty_to_string};
@@ -1589,22 +1589,22 @@ impl LintPass for Stability {
15891589
}
15901590
ast::ExprMethodCall(i, _, _) => {
15911591
span = i.span;
1592-
let method_call = typeck::MethodCall::expr(e.id);
1592+
let method_call = ty::MethodCall::expr(e.id);
15931593
match cx.tcx.method_map.borrow().get(&method_call) {
15941594
Some(method) => {
15951595
match method.origin {
1596-
typeck::MethodStatic(def_id) => {
1596+
ty::MethodStatic(def_id) => {
15971597
def_id
15981598
}
1599-
typeck::MethodStaticUnboxedClosure(def_id) => {
1599+
ty::MethodStaticUnboxedClosure(def_id) => {
16001600
def_id
16011601
}
1602-
typeck::MethodTypeParam(typeck::MethodParam {
1602+
ty::MethodTypeParam(ty::MethodParam {
16031603
ref trait_ref,
16041604
method_num: index,
16051605
..
16061606
}) |
1607-
typeck::MethodTraitObject(typeck::MethodObject {
1607+
ty::MethodTraitObject(ty::MethodObject {
16081608
ref trait_ref,
16091609
method_num: index,
16101610
..

src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use middle::def;
2121
use middle::lang_items;
2222
use middle::resolve;
2323
use middle::ty;
24-
use middle::typeck;
2524
use middle::subst::VecPerParamSpace;
2625

2726
use rbml;
@@ -268,7 +267,7 @@ pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
268267
// Given a def_id for an impl, return information about its vtables
269268
pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
270269
def: ast::DefId)
271-
-> typeck::vtable_res<'tcx> {
270+
-> ty::vtable_res<'tcx> {
272271
let cstore = &tcx.sess.cstore;
273272
let cdata = cstore.get_crate_data(def.krate);
274273
decoder::get_impl_vtables(&*cdata, def.node, tcx)

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use middle::resolve::{TraitItemKind, TypeTraitItemKind};
3030
use middle::subst;
3131
use middle::ty::{ImplContainer, TraitContainer};
3232
use middle::ty::{mod, Ty};
33-
use middle::typeck;
3433
use middle::astencode::vtable_decoder_helpers;
3534

3635
use std::hash::Hash;
@@ -422,7 +421,7 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
422421
pub fn get_impl_vtables<'tcx>(cdata: Cmd,
423422
id: ast::NodeId,
424423
tcx: &ty::ctxt<'tcx>)
425-
-> typeck::vtable_res<'tcx>
424+
-> ty::vtable_res<'tcx>
426425
{
427426
let item_doc = lookup_item(id, cdata.data());
428427
let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);

src/librustc/middle/astencode.rs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use metadata::tyencode;
2626
use middle::mem_categorization::Typer;
2727
use middle::subst;
2828
use middle::subst::VecPerParamSpace;
29-
use middle::typeck::{mod, MethodCall, MethodCallee, MethodOrigin};
30-
use middle::ty::{mod, Ty};
29+
use middle::ty::{mod, Ty, MethodCall, MethodCallee, MethodOrigin};
3130
use util::ppaux::ty_to_string;
3231

3332
use syntax::{ast, ast_map, ast_util, codemap, fold};
@@ -576,12 +575,12 @@ impl tr for ty::UpvarBorrow {
576575

577576
trait read_method_callee_helper<'tcx> {
578577
fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
579-
-> (typeck::ExprAdjustment, MethodCallee<'tcx>);
578+
-> (ty::ExprAdjustment, MethodCallee<'tcx>);
580579
}
581580

582581
fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>,
583582
rbml_w: &mut Encoder,
584-
adjustment: typeck::ExprAdjustment,
583+
adjustment: ty::ExprAdjustment,
585584
method: &MethodCallee<'tcx>) {
586585
use serialize::Encoder;
587586

@@ -603,7 +602,7 @@ fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>,
603602

604603
impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> {
605604
fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
606-
-> (typeck::ExprAdjustment, MethodCallee<'tcx>) {
605+
-> (ty::ExprAdjustment, MethodCallee<'tcx>) {
607606

608607
self.read_struct("MethodCallee", 4, |this| {
609608
let adjustment = this.read_struct_field("adjustment", 0, |this| {
@@ -627,22 +626,22 @@ impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> {
627626
impl<'tcx> tr for MethodOrigin<'tcx> {
628627
fn tr(&self, dcx: &DecodeContext) -> MethodOrigin<'tcx> {
629628
match *self {
630-
typeck::MethodStatic(did) => typeck::MethodStatic(did.tr(dcx)),
631-
typeck::MethodStaticUnboxedClosure(did) => {
632-
typeck::MethodStaticUnboxedClosure(did.tr(dcx))
629+
ty::MethodStatic(did) => ty::MethodStatic(did.tr(dcx)),
630+
ty::MethodStaticUnboxedClosure(did) => {
631+
ty::MethodStaticUnboxedClosure(did.tr(dcx))
633632
}
634-
typeck::MethodTypeParam(ref mp) => {
635-
typeck::MethodTypeParam(
636-
typeck::MethodParam {
633+
ty::MethodTypeParam(ref mp) => {
634+
ty::MethodTypeParam(
635+
ty::MethodParam {
637636
// def-id is already translated when we read it out
638637
trait_ref: mp.trait_ref.clone(),
639638
method_num: mp.method_num,
640639
}
641640
)
642641
}
643-
typeck::MethodTraitObject(ref mo) => {
644-
typeck::MethodTraitObject(
645-
typeck::MethodObject {
642+
ty::MethodTraitObject(ref mo) => {
643+
ty::MethodTraitObject(
644+
ty::MethodObject {
646645
trait_ref: mo.trait_ref.clone(),
647646
.. *mo
648647
}
@@ -687,16 +686,16 @@ pub trait vtable_decoder_helpers<'tcx> {
687686
fn read_vtable_res_with_key(&mut self,
688687
tcx: &ty::ctxt<'tcx>,
689688
cdata: &cstore::crate_metadata)
690-
-> (typeck::ExprAdjustment, typeck::vtable_res<'tcx>);
689+
-> (ty::ExprAdjustment, ty::vtable_res<'tcx>);
691690
fn read_vtable_res(&mut self,
692691
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
693-
-> typeck::vtable_res<'tcx>;
692+
-> ty::vtable_res<'tcx>;
694693
fn read_vtable_param_res(&mut self,
695694
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
696-
-> typeck::vtable_param_res<'tcx>;
695+
-> ty::vtable_param_res<'tcx>;
697696
fn read_vtable_origin(&mut self,
698697
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
699-
-> typeck::vtable_origin<'tcx>;
698+
-> ty::vtable_origin<'tcx>;
700699
}
701700

702701
impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
@@ -714,7 +713,7 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
714713
fn read_vtable_res_with_key(&mut self,
715714
tcx: &ty::ctxt<'tcx>,
716715
cdata: &cstore::crate_metadata)
717-
-> (typeck::ExprAdjustment, typeck::vtable_res<'tcx>) {
716+
-> (ty::ExprAdjustment, ty::vtable_res<'tcx>) {
718717
self.read_struct("VtableWithKey", 2, |this| {
719718
let adjustment = this.read_struct_field("adjustment", 0, |this| {
720719
Decodable::decode(this)
@@ -728,22 +727,22 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
728727
fn read_vtable_res(&mut self,
729728
tcx: &ty::ctxt<'tcx>,
730729
cdata: &cstore::crate_metadata)
731-
-> typeck::vtable_res<'tcx>
730+
-> ty::vtable_res<'tcx>
732731
{
733732
self.read_vec_per_param_space(
734733
|this| this.read_vtable_param_res(tcx, cdata))
735734
}
736735

737736
fn read_vtable_param_res(&mut self,
738737
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
739-
-> typeck::vtable_param_res<'tcx> {
738+
-> ty::vtable_param_res<'tcx> {
740739
self.read_to_vec(|this| Ok(this.read_vtable_origin(tcx, cdata)))
741740
.unwrap().into_iter().collect()
742741
}
743742

744743
fn read_vtable_origin(&mut self,
745744
tcx: &ty::ctxt<'tcx>, cdata: &cstore::crate_metadata)
746-
-> typeck::vtable_origin<'tcx> {
745+
-> ty::vtable_origin<'tcx> {
747746
self.read_enum("vtable_origin", |this| {
748747
this.read_enum_variant(&["vtable_static",
749748
"vtable_param",
@@ -752,7 +751,7 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
752751
|this, i| {
753752
Ok(match i {
754753
0 => {
755-
typeck::vtable_static(
754+
ty::vtable_static(
756755
this.read_enum_variant_arg(0u, |this| {
757756
Ok(this.read_def_id_nodcx(cdata))
758757
}).unwrap(),
@@ -765,7 +764,7 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
765764
)
766765
}
767766
1 => {
768-
typeck::vtable_param(
767+
ty::vtable_param(
769768
this.read_enum_variant_arg(0u, |this| {
770769
Decodable::decode(this)
771770
}).unwrap(),
@@ -775,14 +774,14 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
775774
)
776775
}
777776
2 => {
778-
typeck::vtable_unboxed_closure(
777+
ty::vtable_unboxed_closure(
779778
this.read_enum_variant_arg(0u, |this| {
780779
Ok(this.read_def_id_nodcx(cdata))
781780
}).unwrap()
782781
)
783782
}
784783
3 => {
785-
typeck::vtable_error
784+
ty::vtable_error
786785
}
787786
_ => panic!("bad enum variant")
788787
})
@@ -826,7 +825,7 @@ trait rbml_writer_helpers<'tcx> {
826825
closure_type: &ty::ClosureTy<'tcx>);
827826
fn emit_method_origin<'a>(&mut self,
828827
ecx: &e::EncodeContext<'a, 'tcx>,
829-
method_origin: &typeck::MethodOrigin<'tcx>);
828+
method_origin: &ty::MethodOrigin<'tcx>);
830829
fn emit_ty<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, ty: Ty<'tcx>);
831830
fn emit_tys<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, tys: &[Ty<'tcx>]);
832831
fn emit_type_param_def<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
@@ -860,25 +859,25 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
860859

861860
fn emit_method_origin<'a>(&mut self,
862861
ecx: &e::EncodeContext<'a, 'tcx>,
863-
method_origin: &typeck::MethodOrigin<'tcx>)
862+
method_origin: &ty::MethodOrigin<'tcx>)
864863
{
865864
use serialize::Encoder;
866865

867866
self.emit_enum("MethodOrigin", |this| {
868867
match *method_origin {
869-
typeck::MethodStatic(def_id) => {
868+
ty::MethodStatic(def_id) => {
870869
this.emit_enum_variant("MethodStatic", 0, 1, |this| {
871870
Ok(this.emit_def_id(def_id))
872871
})
873872
}
874873

875-
typeck::MethodStaticUnboxedClosure(def_id) => {
874+
ty::MethodStaticUnboxedClosure(def_id) => {
876875
this.emit_enum_variant("MethodStaticUnboxedClosure", 1, 1, |this| {
877876
Ok(this.emit_def_id(def_id))
878877
})
879878
}
880879

881-
typeck::MethodTypeParam(ref p) => {
880+
ty::MethodTypeParam(ref p) => {
882881
this.emit_enum_variant("MethodTypeParam", 2, 1, |this| {
883882
this.emit_struct("MethodParam", 2, |this| {
884883
try!(this.emit_struct_field("trait_ref", 0, |this| {
@@ -892,7 +891,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
892891
})
893892
}
894893

895-
typeck::MethodTraitObject(ref o) => {
894+
ty::MethodTraitObject(ref o) => {
896895
this.emit_enum_variant("MethodTraitObject", 3, 1, |this| {
897896
this.emit_struct("MethodObject", 2, |this| {
898897
try!(this.emit_struct_field("trait_ref", 0, |this| {
@@ -1330,7 +1329,7 @@ impl<'a> doc_decoder_helpers for rbml::Doc<'a> {
13301329

13311330
trait rbml_decoder_decoder_helpers<'tcx> {
13321331
fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1333-
-> typeck::MethodOrigin<'tcx>;
1332+
-> ty::MethodOrigin<'tcx>;
13341333
fn read_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Ty<'tcx>;
13351334
fn read_tys<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Vec<Ty<'tcx>>;
13361335
fn read_trait_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
@@ -1409,7 +1408,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
14091408
}
14101409

14111410
fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1412-
-> typeck::MethodOrigin<'tcx>
1411+
-> ty::MethodOrigin<'tcx>
14131412
{
14141413
self.read_enum("MethodOrigin", |this| {
14151414
let variants = &["MethodStatic", "MethodStaticUnboxedClosure",
@@ -1418,18 +1417,18 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
14181417
Ok(match i {
14191418
0 => {
14201419
let def_id = this.read_def_id(dcx);
1421-
typeck::MethodStatic(def_id)
1420+
ty::MethodStatic(def_id)
14221421
}
14231422

14241423
1 => {
14251424
let def_id = this.read_def_id(dcx);
1426-
typeck::MethodStaticUnboxedClosure(def_id)
1425+
ty::MethodStaticUnboxedClosure(def_id)
14271426
}
14281427

14291428
2 => {
14301429
this.read_struct("MethodTypeParam", 2, |this| {
1431-
Ok(typeck::MethodTypeParam(
1432-
typeck::MethodParam {
1430+
Ok(ty::MethodTypeParam(
1431+
ty::MethodParam {
14331432
trait_ref: {
14341433
this.read_struct_field("trait_ref", 0, |this| {
14351434
Ok(this.read_trait_ref(dcx))
@@ -1446,8 +1445,8 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
14461445

14471446
3 => {
14481447
this.read_struct("MethodTraitObject", 2, |this| {
1449-
Ok(typeck::MethodTraitObject(
1450-
typeck::MethodObject {
1448+
Ok(ty::MethodTraitObject(
1449+
ty::MethodObject {
14511450
trait_ref: {
14521451
this.read_struct_field("trait_ref", 0, |this| {
14531452
Ok(this.read_trait_ref(dcx))

src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use middle::cfg::*;
1212
use middle::def;
1313
use middle::graph;
1414
use middle::region::CodeExtent;
15-
use middle::typeck;
1615
use middle::ty;
1716
use syntax::ast;
1817
use syntax::ast_util;
@@ -510,7 +509,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
510509
pred: CFGIndex,
511510
func_or_rcvr: &ast::Expr,
512511
args: I) -> CFGIndex {
513-
let method_call = typeck::MethodCall::expr(call_expr.id);
512+
let method_call = ty::MethodCall::expr(call_expr.id);
514513
let return_ty = ty::ty_fn_ret(match self.tcx.method_map.borrow().get(&method_call) {
515514
Some(method) => method.ty,
516515
None => ty::expr_ty(self.tcx, func_or_rcvr)
@@ -635,7 +634,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
635634
}
636635

637636
fn is_method_call(&self, expr: &ast::Expr) -> bool {
638-
let method_call = typeck::MethodCall::expr(expr.id);
637+
let method_call = ty::MethodCall::expr(expr.id);
639638
self.tcx.method_map.borrow().contains_key(&method_call)
640639
}
641640
}

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use middle::def::*;
1313
use middle::ty;
14-
use middle::typeck;
1514
use util::ppaux;
1615

1716
use syntax::ast;
@@ -111,7 +110,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) -> bool {
111110
}
112111
ast::ExprLit(ref lit) if ast_util::lit_is_str(&**lit) => {}
113112
ast::ExprBinary(..) | ast::ExprUnary(..) => {
114-
let method_call = typeck::MethodCall::expr(e.id);
113+
let method_call = ty::MethodCall::expr(e.id);
115114
if v.tcx.method_map.borrow().contains_key(&method_call) {
116115
span_err!(v.tcx.sess, e.span, E0011,
117116
"user-defined operators are not allowed in constant \

0 commit comments

Comments
 (0)