Skip to content

Commit b1c9616

Browse files
committed
Auto merge of #28274 - arielb1:split-ty, r=nikomatsakis
That file got way too big for its own good. It could be split more - this is just a start. r? @nikomatsakis
2 parents e629dba + 5a95acb commit b1c9616

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+8697
-8432
lines changed

src/librustc/lib.rs

-8
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ pub mod front {
107107
pub mod middle {
108108
pub mod astconv_util;
109109
pub mod astencode;
110-
pub mod cast;
111110
pub mod cfg;
112111
pub mod check_const;
113112
pub mod check_static_recursion;
@@ -124,15 +123,13 @@ pub mod middle {
124123
pub mod effect;
125124
pub mod entry;
126125
pub mod expr_use_visitor;
127-
pub mod fast_reject;
128126
pub mod free_region;
129127
pub mod intrinsicck;
130128
pub mod infer;
131129
pub mod implicator;
132130
pub mod lang_items;
133131
pub mod liveness;
134132
pub mod mem_categorization;
135-
pub mod outlives;
136133
pub mod pat_util;
137134
pub mod privacy;
138135
pub mod reachable;
@@ -143,11 +140,6 @@ pub mod middle {
143140
pub mod subst;
144141
pub mod traits;
145142
pub mod ty;
146-
pub mod ty_fold;
147-
pub mod ty_match;
148-
pub mod ty_relate;
149-
pub mod ty_walk;
150-
pub mod wf;
151143
pub mod weak_lang_items;
152144
}
153145

src/librustc/metadata/csearch.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,11 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
247247
decoder::get_impl_polarity(&*cdata, def.node)
248248
}
249249

250-
pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
251-
def: DefId)
252-
-> Option<ty::CustomCoerceUnsized> {
250+
pub fn get_custom_coerce_unsized_kind<'tcx>(
251+
tcx: &ty::ctxt<'tcx>,
252+
def: DefId)
253+
-> Option<ty::adjustment::CustomCoerceUnsized>
254+
{
253255
let cstore = &tcx.sess.cstore;
254256
let cdata = cstore.get_crate_data(def.krate);
255257
decoder::get_custom_coerce_unsized_kind(&*cdata, def.node)

src/librustc/metadata/decoder.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,11 @@ pub fn get_impl_polarity<'tcx>(cdata: Cmd,
540540
}
541541
}
542542

543-
pub fn get_custom_coerce_unsized_kind<'tcx>(cdata: Cmd,
544-
id: ast::NodeId)
545-
-> Option<ty::CustomCoerceUnsized> {
543+
pub fn get_custom_coerce_unsized_kind<'tcx>(
544+
cdata: Cmd,
545+
id: ast::NodeId)
546+
-> Option<ty::adjustment::CustomCoerceUnsized>
547+
{
546548
let item_doc = cdata.lookup_item(id);
547549
reader::maybe_get_doc(item_doc, tag_impl_coerce_unsized_kind).map(|kind_doc| {
548550
let mut decoder = reader::Decoder::new(kind_doc);

src/librustc/middle/astencode.rs

+31-29
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use metadata::tydecode;
2727
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId};
2828
use metadata::tydecode::{RegionParameter, ClosureSource};
2929
use metadata::tyencode;
30-
use middle::cast;
30+
use middle::ty::adjustment;
31+
use middle::ty::cast;
3132
use middle::check_const::ConstQualif;
3233
use middle::def;
3334
use middle::def_id::{DefId, LOCAL_CRATE};
@@ -646,11 +647,11 @@ trait rbml_writer_helpers<'tcx> {
646647
fn emit_builtin_bounds(&mut self, ecx: &e::EncodeContext, bounds: &ty::BuiltinBounds);
647648
fn emit_upvar_capture(&mut self, ecx: &e::EncodeContext, capture: &ty::UpvarCapture);
648649
fn emit_auto_adjustment<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
649-
adj: &ty::AutoAdjustment<'tcx>);
650+
adj: &adjustment::AutoAdjustment<'tcx>);
650651
fn emit_autoref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
651-
autoref: &ty::AutoRef<'tcx>);
652+
autoref: &adjustment::AutoRef<'tcx>);
652653
fn emit_auto_deref_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
653-
auto_deref_ref: &ty::AutoDerefRef<'tcx>);
654+
auto_deref_ref: &adjustment::AutoDerefRef<'tcx>);
654655
}
655656

656657
impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
@@ -771,22 +772,22 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
771772
}
772773

773774
fn emit_auto_adjustment<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>,
774-
adj: &ty::AutoAdjustment<'tcx>) {
775+
adj: &adjustment::AutoAdjustment<'tcx>) {
775776
use serialize::Encoder;
776777

777778
self.emit_enum("AutoAdjustment", |this| {
778779
match *adj {
779-
ty::AdjustReifyFnPointer=> {
780+
adjustment::AdjustReifyFnPointer=> {
780781
this.emit_enum_variant("AdjustReifyFnPointer", 1, 0, |_| Ok(()))
781782
}
782783

783-
ty::AdjustUnsafeFnPointer => {
784+
adjustment::AdjustUnsafeFnPointer => {
784785
this.emit_enum_variant("AdjustUnsafeFnPointer", 2, 0, |_| {
785786
Ok(())
786787
})
787788
}
788789

789-
ty::AdjustDerefRef(ref auto_deref_ref) => {
790+
adjustment::AdjustDerefRef(ref auto_deref_ref) => {
790791
this.emit_enum_variant("AdjustDerefRef", 3, 2, |this| {
791792
this.emit_enum_variant_arg(0,
792793
|this| Ok(this.emit_auto_deref_ref(ecx, auto_deref_ref)))
@@ -797,19 +798,19 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
797798
}
798799

799800
fn emit_autoref<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>,
800-
autoref: &ty::AutoRef<'tcx>) {
801+
autoref: &adjustment::AutoRef<'tcx>) {
801802
use serialize::Encoder;
802803

803804
self.emit_enum("AutoRef", |this| {
804805
match autoref {
805-
&ty::AutoPtr(r, m) => {
806+
&adjustment::AutoPtr(r, m) => {
806807
this.emit_enum_variant("AutoPtr", 0, 2, |this| {
807808
this.emit_enum_variant_arg(0,
808809
|this| Ok(this.emit_region(ecx, *r)));
809810
this.emit_enum_variant_arg(1, |this| m.encode(this))
810811
})
811812
}
812-
&ty::AutoUnsafe(m) => {
813+
&adjustment::AutoUnsafe(m) => {
813814
this.emit_enum_variant("AutoUnsafe", 1, 1, |this| {
814815
this.emit_enum_variant_arg(0, |this| m.encode(this))
815816
})
@@ -819,7 +820,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
819820
}
820821

821822
fn emit_auto_deref_ref<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>,
822-
auto_deref_ref: &ty::AutoDerefRef<'tcx>) {
823+
auto_deref_ref: &adjustment::AutoDerefRef<'tcx>) {
823824
use serialize::Encoder;
824825

825826
self.emit_struct("AutoDerefRef", 2, |this| {
@@ -974,7 +975,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
974975

975976
if let Some(adjustment) = tcx.tables.borrow().adjustments.get(&id) {
976977
match *adjustment {
977-
ty::AdjustDerefRef(ref adj) => {
978+
adjustment::AdjustDerefRef(ref adj) => {
978979
for autoderef in 0..adj.autoderefs {
979980
let method_call = ty::MethodCall::autoderef(id, autoderef as u32);
980981
if let Some(method) = tcx.tables.borrow().method_map.get(&method_call) {
@@ -1063,17 +1064,17 @@ trait rbml_decoder_decoder_helpers<'tcx> {
10631064
fn read_upvar_capture(&mut self, dcx: &DecodeContext)
10641065
-> ty::UpvarCapture;
10651066
fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1066-
-> ty::AutoAdjustment<'tcx>;
1067+
-> adjustment::AutoAdjustment<'tcx>;
10671068
fn read_cast_kind<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
10681069
-> cast::CastKind;
10691070
fn read_closure_kind<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
10701071
-> ty::ClosureKind;
10711072
fn read_closure_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
10721073
-> ty::ClosureTy<'tcx>;
10731074
fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1074-
-> ty::AutoDerefRef<'tcx>;
1075+
-> adjustment::AutoDerefRef<'tcx>;
10751076
fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1076-
-> ty::AutoRef<'tcx>;
1077+
-> adjustment::AutoRef<'tcx>;
10771078
fn convert_def_id(&mut self,
10781079
dcx: &DecodeContext,
10791080
source: DefIdSource,
@@ -1246,30 +1247,30 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12461247
}).unwrap()
12471248
}
12481249
fn read_auto_adjustment<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
1249-
-> ty::AutoAdjustment<'tcx> {
1250+
-> adjustment::AutoAdjustment<'tcx> {
12501251
self.read_enum("AutoAdjustment", |this| {
12511252
let variants = ["AdjustReifyFnPointer", "AdjustUnsafeFnPointer", "AdjustDerefRef"];
12521253
this.read_enum_variant(&variants, |this, i| {
12531254
Ok(match i {
1254-
1 => ty::AdjustReifyFnPointer,
1255-
2 => ty::AdjustUnsafeFnPointer,
1255+
1 => adjustment::AdjustReifyFnPointer,
1256+
2 => adjustment::AdjustUnsafeFnPointer,
12561257
3 => {
1257-
let auto_deref_ref: ty::AutoDerefRef =
1258+
let auto_deref_ref: adjustment::AutoDerefRef =
12581259
this.read_enum_variant_arg(0,
12591260
|this| Ok(this.read_auto_deref_ref(dcx))).unwrap();
12601261

1261-
ty::AdjustDerefRef(auto_deref_ref)
1262+
adjustment::AdjustDerefRef(auto_deref_ref)
12621263
}
1263-
_ => panic!("bad enum variant for ty::AutoAdjustment")
1264+
_ => panic!("bad enum variant for adjustment::AutoAdjustment")
12641265
})
12651266
})
12661267
}).unwrap()
12671268
}
12681269

12691270
fn read_auto_deref_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
1270-
-> ty::AutoDerefRef<'tcx> {
1271+
-> adjustment::AutoDerefRef<'tcx> {
12711272
self.read_struct("AutoDerefRef", 2, |this| {
1272-
Ok(ty::AutoDerefRef {
1273+
Ok(adjustment::AutoDerefRef {
12731274
autoderefs: this.read_struct_field("autoderefs", 0, |this| {
12741275
Decodable::decode(this)
12751276
}).unwrap(),
@@ -1296,7 +1297,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12961297
}
12971298

12981299
fn read_autoref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
1299-
-> ty::AutoRef<'tcx> {
1300+
-> adjustment::AutoRef<'tcx> {
13001301
self.read_enum("AutoRef", |this| {
13011302
let variants = ["AutoPtr", "AutoUnsafe"];
13021303
this.read_enum_variant(&variants, |this, i| {
@@ -1311,15 +1312,15 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
13111312
Decodable::decode(this)
13121313
}).unwrap();
13131314

1314-
ty::AutoPtr(dcx.tcx.mk_region(r), m)
1315+
adjustment::AutoPtr(dcx.tcx.mk_region(r), m)
13151316
}
13161317
1 => {
13171318
let m: hir::Mutability =
13181319
this.read_enum_variant_arg(0, |this| Decodable::decode(this)).unwrap();
13191320

1320-
ty::AutoUnsafe(m)
1321+
adjustment::AutoUnsafe(m)
13211322
}
1322-
_ => panic!("bad enum variant for ty::AutoRef")
1323+
_ => panic!("bad enum variant for adjustment::AutoRef")
13231324
})
13241325
})
13251326
}).unwrap()
@@ -1467,7 +1468,8 @@ fn decode_side_tables(dcx: &DecodeContext,
14671468
dcx.tcx.tables.borrow_mut().method_map.insert(method_call, method);
14681469
}
14691470
c::tag_table_adjustments => {
1470-
let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(dcx);
1471+
let adj =
1472+
val_dsr.read_auto_adjustment(dcx);
14711473
dcx.tcx.tables.borrow_mut().adjustments.insert(id, adj);
14721474
}
14731475
c::tag_table_closure_tys => {

src/librustc/middle/check_const.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// - It's not possible to take the address of a static item with unsafe interior. This is enforced
2525
// by borrowck::gather_loans
2626

27-
use middle::cast::{CastKind};
27+
use middle::ty::cast::{CastKind};
2828
use middle::const_eval;
2929
use middle::const_eval::EvalHint::ExprTypeChecked;
3030
use middle::def;
@@ -798,8 +798,13 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
798798
/// Check the adjustments of an expression
799799
fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) {
800800
match v.tcx.tables.borrow().adjustments.get(&e.id) {
801-
None | Some(&ty::AdjustReifyFnPointer) | Some(&ty::AdjustUnsafeFnPointer) => {}
802-
Some(&ty::AdjustDerefRef(ty::AutoDerefRef { autoderefs, .. })) => {
801+
None |
802+
Some(&ty::adjustment::AdjustReifyFnPointer) |
803+
Some(&ty::adjustment::AdjustUnsafeFnPointer) => {}
804+
805+
Some(&ty::adjustment::AdjustDerefRef(
806+
ty::adjustment::AutoDerefRef { autoderefs, .. }
807+
)) => {
803808
if (0..autoderefs as u32).any(|autoderef| {
804809
v.tcx.is_overloaded_autoderef(e.id, autoderef)
805810
}) {

src/librustc/middle/expr_use_visitor.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use middle::def_id::{DefId};
2525
use middle::infer;
2626
use middle::mem_categorization as mc;
2727
use middle::ty;
28+
use middle::ty::adjustment;
2829

2930
use rustc_front::hir;
3031

@@ -726,16 +727,16 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
726727
let adj = typer.adjustments().get(&expr.id).map(|x| x.clone());
727728
if let Some(adjustment) = adj {
728729
match adjustment {
729-
ty::AdjustReifyFnPointer |
730-
ty::AdjustUnsafeFnPointer => {
730+
adjustment::AdjustReifyFnPointer |
731+
adjustment::AdjustUnsafeFnPointer => {
731732
// Creating a closure/fn-pointer or unsizing consumes
732733
// the input and stores it into the resulting rvalue.
733734
debug!("walk_adjustment(AdjustReifyFnPointer|AdjustUnsafeFnPointer)");
734735
let cmt_unadjusted =
735736
return_if_err!(self.mc.cat_expr_unadjusted(expr));
736737
self.delegate_consume(expr.id, expr.span, cmt_unadjusted);
737738
}
738-
ty::AdjustDerefRef(ref adj) => {
739+
adjustment::AdjustDerefRef(ref adj) => {
739740
self.walk_autoderefref(expr, adj);
740741
}
741742
}
@@ -778,7 +779,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
778779

779780
fn walk_autoderefref(&mut self,
780781
expr: &hir::Expr,
781-
adj: &ty::AutoDerefRef<'tcx>) {
782+
adj: &adjustment::AutoDerefRef<'tcx>) {
782783
debug!("walk_autoderefref expr={:?} adj={:?}",
783784
expr,
784785
adj);
@@ -809,7 +810,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
809810
fn walk_autoref(&mut self,
810811
expr: &hir::Expr,
811812
cmt_base: mc::cmt<'tcx>,
812-
opt_autoref: Option<ty::AutoRef<'tcx>>)
813+
opt_autoref: Option<adjustment::AutoRef<'tcx>>)
813814
-> mc::cmt<'tcx>
814815
{
815816
debug!("walk_autoref(expr.id={} cmt_derefd={:?} opt_autoref={:?})",
@@ -828,7 +829,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
828829
};
829830

830831
match *autoref {
831-
ty::AutoPtr(r, m) => {
832+
adjustment::AutoPtr(r, m) => {
832833
self.delegate.borrow(expr.id,
833834
expr.span,
834835
cmt_base,
@@ -837,7 +838,7 @@ impl<'d,'t,'a,'tcx> ExprUseVisitor<'d,'t,'a,'tcx> {
837838
AutoRef);
838839
}
839840

840-
ty::AutoUnsafe(m) => {
841+
adjustment::AutoUnsafe(m) => {
841842
debug!("walk_autoref: expr.id={} cmt_base={:?}",
842843
expr.id,
843844
cmt_base);

src/librustc/middle/free_region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! region outlives another and so forth.
1717
1818
use middle::ty::{self, FreeRegion, Region};
19-
use middle::wf::ImpliedBound;
19+
use middle::ty::wf::ImpliedBound;
2020
use rustc_data_structures::transitive_relation::TransitiveRelation;
2121

2222
#[derive(Clone)]

src/librustc/middle/implicator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use middle::infer::{InferCtxt, GenericKind};
1515
use middle::subst::Substs;
1616
use middle::traits;
1717
use middle::ty::{self, RegionEscape, ToPredicate, Ty};
18-
use middle::ty_fold::{TypeFoldable, TypeFolder};
18+
use middle::ty::fold::{TypeFoldable, TypeFolder};
1919

2020
use syntax::ast;
2121
use syntax::codemap::Span;

src/librustc/middle/infer/bivariate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use super::type_variable::{BiTo};
3030

3131
use middle::ty::{self, Ty};
3232
use middle::ty::TyVar;
33-
use middle::ty_relate::{Relate, RelateResult, TypeRelation};
33+
use middle::ty::relate::{Relate, RelateResult, TypeRelation};
3434

3535
pub struct Bivariate<'a, 'tcx: 'a> {
3636
fields: CombineFields<'a, 'tcx>

0 commit comments

Comments
 (0)