Skip to content

Commit e6ce31e

Browse files
committed
---
yaml --- r: 217963 b: refs/heads/auto c: 70365ed h: refs/heads/master i: 217961: 1b99a85 217959: 7214b08 v: v3
1 parent aeb308f commit e6ce31e

File tree

24 files changed

+329
-692
lines changed

24 files changed

+329
-692
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: fe354e58bdd17ad63f2d9278820eb7ee1ee091d5
11+
refs/heads/auto: 70365ed911d418c22d2d9e6a972929b946b6a3ac
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/src/librustc/middle/astencode.rs

Lines changed: 54 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use middle::check_const::ConstQualif;
2929
use middle::privacy::{AllPublic, LastMod};
3030
use middle::subst;
3131
use middle::subst::VecPerParamSpace;
32-
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
32+
use middle::ty::{self, Ty};
3333

3434
use syntax::{ast, ast_util, codemap, fold};
3535
use syntax::codemap::Span;
@@ -600,48 +600,54 @@ impl tr for ty::UpvarCapture {
600600

601601
trait read_method_callee_helper<'tcx> {
602602
fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
603-
-> (u32, MethodCallee<'tcx>);
603+
-> (u32, ty::MethodCallee<'tcx>);
604604
}
605605

606606
fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>,
607607
rbml_w: &mut Encoder,
608608
autoderef: u32,
609-
method: &MethodCallee<'tcx>) {
609+
method: &ty::MethodCallee<'tcx>) {
610610
use serialize::Encoder;
611611

612-
rbml_w.emit_struct("MethodCallee", 4, |rbml_w| {
612+
rbml_w.emit_struct("MethodCallee", 5, |rbml_w| {
613613
rbml_w.emit_struct_field("autoderef", 0, |rbml_w| {
614614
autoderef.encode(rbml_w)
615615
});
616-
rbml_w.emit_struct_field("origin", 1, |rbml_w| {
617-
Ok(rbml_w.emit_method_origin(ecx, &method.origin))
616+
rbml_w.emit_struct_field("def_id", 1, |rbml_w| {
617+
Ok(rbml_w.emit_def_id(method.def_id))
618618
});
619-
rbml_w.emit_struct_field("ty", 2, |rbml_w| {
619+
rbml_w.emit_struct_field("origin", 2, |rbml_w| {
620+
Ok(rbml_w.emit_method_origin(method.origin))
621+
});
622+
rbml_w.emit_struct_field("ty", 3, |rbml_w| {
620623
Ok(rbml_w.emit_ty(ecx, method.ty))
621624
});
622-
rbml_w.emit_struct_field("substs", 3, |rbml_w| {
625+
rbml_w.emit_struct_field("substs", 4, |rbml_w| {
623626
Ok(rbml_w.emit_substs(ecx, &method.substs))
624627
})
625628
}).unwrap();
626629
}
627630

628631
impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> {
629632
fn read_method_callee<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
630-
-> (u32, MethodCallee<'tcx>) {
633+
-> (u32, ty::MethodCallee<'tcx>) {
631634

632-
self.read_struct("MethodCallee", 4, |this| {
635+
self.read_struct("MethodCallee", 5, |this| {
633636
let autoderef = this.read_struct_field("autoderef", 0, |this| {
634637
Decodable::decode(this)
635638
}).unwrap();
636-
Ok((autoderef, MethodCallee {
637-
origin: this.read_struct_field("origin", 1, |this| {
639+
Ok((autoderef, ty::MethodCallee {
640+
def_id: this.read_struct_field("def_id", 1, |this| {
641+
Ok(this.read_def_id(dcx))
642+
}).unwrap(),
643+
origin: this.read_struct_field("origin", 2, |this| {
638644
Ok(this.read_method_origin(dcx))
639645
}).unwrap(),
640-
ty: this.read_struct_field("ty", 2, |this| {
646+
ty: this.read_struct_field("ty", 3, |this| {
641647
Ok(this.read_ty(dcx))
642648
}).unwrap(),
643-
substs: this.read_struct_field("substs", 3, |this| {
644-
Ok(this.read_substs(dcx))
649+
substs: this.read_struct_field("substs", 4, |this| {
650+
Ok(dcx.tcx.mk_substs(this.read_substs(dcx)))
645651
}).unwrap()
646652
}))
647653
}).unwrap()
@@ -707,9 +713,7 @@ impl<'a, 'tcx> get_ty_str_ctxt<'tcx> for e::EncodeContext<'a, 'tcx> {
707713
trait rbml_writer_helpers<'tcx> {
708714
fn emit_closure_type<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
709715
closure_type: &ty::ClosureTy<'tcx>);
710-
fn emit_method_origin<'a>(&mut self,
711-
ecx: &e::EncodeContext<'a, 'tcx>,
712-
method_origin: &ty::MethodOrigin<'tcx>);
716+
fn emit_method_origin(&mut self, method_origin: ty::MethodOrigin);
713717
fn emit_ty<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, ty: Ty<'tcx>);
714718
fn emit_tys<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, tys: &[Ty<'tcx>]);
715719
fn emit_type_param_def<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>,
@@ -741,61 +745,31 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
741745
});
742746
}
743747

744-
fn emit_method_origin<'b>(&mut self,
745-
ecx: &e::EncodeContext<'b, 'tcx>,
746-
method_origin: &ty::MethodOrigin<'tcx>)
747-
{
748+
fn emit_method_origin(&mut self, method_origin: ty::MethodOrigin) {
748749
use serialize::Encoder;
749750

750751
self.emit_enum("MethodOrigin", |this| {
751-
match *method_origin {
752-
ty::MethodStatic(def_id) => {
753-
this.emit_enum_variant("MethodStatic", 0, 1, |this| {
754-
Ok(this.emit_def_id(def_id))
755-
})
752+
match method_origin {
753+
ty::MethodOrigin::Inherent => {
754+
this.emit_enum_variant("Inherent", 0, 0, |_| Ok(()))
756755
}
757756

758-
ty::MethodTypeParam(ref p) => {
759-
this.emit_enum_variant("MethodTypeParam", 1, 1, |this| {
760-
this.emit_struct("MethodParam", 2, |this| {
761-
try!(this.emit_struct_field("trait_ref", 0, |this| {
762-
Ok(this.emit_trait_ref(ecx, &p.trait_ref))
763-
}));
764-
try!(this.emit_struct_field("method_num", 0, |this| {
765-
this.emit_uint(p.method_num)
766-
}));
767-
try!(this.emit_struct_field("impl_def_id", 0, |this| {
768-
this.emit_option(|this| {
769-
match p.impl_def_id {
770-
None => this.emit_option_none(),
771-
Some(did) => this.emit_option_some(|this| {
772-
Ok(this.emit_def_id(did))
773-
})
774-
}
757+
ty::MethodOrigin::Trait(impl_def_id) => {
758+
this.emit_enum_variant("Trait", 1, 1, |this| {
759+
this.emit_option(|this| {
760+
match impl_def_id {
761+
None => this.emit_option_none(),
762+
Some(did) => this.emit_option_some(|this| {
763+
Ok(this.emit_def_id(did))
775764
})
776-
}));
777-
Ok(())
765+
}
778766
})
779767
})
780768
}
781769

782-
ty::MethodTraitObject(ref o) => {
783-
this.emit_enum_variant("MethodTraitObject", 2, 1, |this| {
784-
this.emit_struct("MethodObject", 2, |this| {
785-
try!(this.emit_struct_field("trait_ref", 0, |this| {
786-
Ok(this.emit_trait_ref(ecx, &o.trait_ref))
787-
}));
788-
try!(this.emit_struct_field("object_trait_id", 0, |this| {
789-
Ok(this.emit_def_id(o.object_trait_id))
790-
}));
791-
try!(this.emit_struct_field("method_num", 0, |this| {
792-
this.emit_uint(o.method_num)
793-
}));
794-
try!(this.emit_struct_field("vtable_index", 0, |this| {
795-
this.emit_uint(o.vtable_index)
796-
}));
797-
Ok(())
798-
})
770+
ty::MethodOrigin::Object(vtable_index) => {
771+
this.emit_enum_variant("Object", 2, 1, |this| {
772+
this.emit_uint(vtable_index)
799773
})
800774
}
801775
}
@@ -1071,7 +1045,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10711045
})
10721046
}
10731047

1074-
let method_call = MethodCall::expr(id);
1048+
let method_call = ty::MethodCall::expr(id);
10751049
if let Some(method) = tcx.tables.borrow().method_map.get(&method_call) {
10761050
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
10771051
rbml_w.id(id);
@@ -1083,7 +1057,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10831057
match *adjustment {
10841058
ty::AdjustDerefRef(ref adj) => {
10851059
for autoderef in 0..adj.autoderefs {
1086-
let method_call = MethodCall::autoderef(id, autoderef as u32);
1060+
let method_call = ty::MethodCall::autoderef(id, autoderef as u32);
10871061
if let Some(method) = tcx.tables.borrow().method_map.get(&method_call) {
10881062
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
10891063
rbml_w.id(id);
@@ -1144,8 +1118,7 @@ impl<'a> doc_decoder_helpers for rbml::Doc<'a> {
11441118
}
11451119

11461120
trait rbml_decoder_decoder_helpers<'tcx> {
1147-
fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
1148-
-> ty::MethodOrigin<'tcx>;
1121+
fn read_method_origin(&mut self, dcx: &DecodeContext) -> ty::MethodOrigin;
11491122
fn read_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Ty<'tcx>;
11501123
fn read_tys<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Vec<Ty<'tcx>>;
11511124
fn read_trait_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
@@ -1229,77 +1202,25 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
12291202
}).unwrap()
12301203
}
12311204

1232-
fn read_method_origin<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
1233-
-> ty::MethodOrigin<'tcx>
1234-
{
1205+
fn read_method_origin(&mut self, dcx: &DecodeContext) -> ty::MethodOrigin {
12351206
self.read_enum("MethodOrigin", |this| {
1236-
let variants = &["MethodStatic", "MethodTypeParam", "MethodTraitObject"];
1207+
let variants = &["Inherent", "Trait", "Object"];
12371208
this.read_enum_variant(variants, |this, i| {
1238-
Ok(match i {
1239-
0 => {
1240-
let def_id = this.read_def_id(dcx);
1241-
ty::MethodStatic(def_id)
1242-
}
1209+
match i {
1210+
0 => Ok(ty::MethodOrigin::Inherent),
12431211

1244-
1 => {
1245-
this.read_struct("MethodTypeParam", 2, |this| {
1246-
Ok(ty::MethodTypeParam(
1247-
ty::MethodParam {
1248-
trait_ref: {
1249-
this.read_struct_field("trait_ref", 0, |this| {
1250-
Ok(this.read_trait_ref(dcx))
1251-
}).unwrap()
1252-
},
1253-
method_num: {
1254-
this.read_struct_field("method_num", 1, |this| {
1255-
this.read_uint()
1256-
}).unwrap()
1257-
},
1258-
impl_def_id: {
1259-
this.read_struct_field("impl_def_id", 2, |this| {
1260-
this.read_option(|this, b| {
1261-
if b {
1262-
Ok(Some(this.read_def_id(dcx)))
1263-
} else {
1264-
Ok(None)
1265-
}
1266-
})
1267-
}).unwrap()
1268-
}
1269-
}))
1270-
}).unwrap()
1271-
}
1212+
1 => this.read_option(|this, b| {
1213+
Ok(ty::MethodOrigin::Trait(if b {
1214+
Some(this.read_def_id(dcx))
1215+
} else {
1216+
None
1217+
}))
1218+
}),
12721219

1273-
2 => {
1274-
this.read_struct("MethodTraitObject", 2, |this| {
1275-
Ok(ty::MethodTraitObject(
1276-
ty::MethodObject {
1277-
trait_ref: {
1278-
this.read_struct_field("trait_ref", 0, |this| {
1279-
Ok(this.read_trait_ref(dcx))
1280-
}).unwrap()
1281-
},
1282-
object_trait_id: {
1283-
this.read_struct_field("object_trait_id", 1, |this| {
1284-
Ok(this.read_def_id(dcx))
1285-
}).unwrap()
1286-
},
1287-
method_num: {
1288-
this.read_struct_field("method_num", 2, |this| {
1289-
this.read_uint()
1290-
}).unwrap()
1291-
},
1292-
vtable_index: {
1293-
this.read_struct_field("vtable_index", 3, |this| {
1294-
this.read_uint()
1295-
}).unwrap()
1296-
},
1297-
}))
1298-
}).unwrap()
1299-
}
1220+
2 => this.read_uint().map(|idx| ty::MethodOrigin::Object(idx)),
13001221

13011222
_ => panic!("..")
1302-
})
1223+
}
13031224
})
13041225
}).unwrap()
13051226
}
@@ -1651,7 +1572,7 @@ fn decode_side_tables(dcx: &DecodeContext,
16511572
}
16521573
c::tag_table_method_map => {
16531574
let (autoderef, method) = val_dsr.read_method_callee(dcx);
1654-
let method_call = MethodCall {
1575+
let method_call = ty::MethodCall {
16551576
expr_id: id,
16561577
autoderef: autoderef
16571578
};

branches/auto/src/librustc/middle/check_const.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,13 +696,11 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
696696
}
697697
}
698698
ast::ExprMethodCall(..) => {
699-
let method_did = match v.tcx.tables.borrow().method_map[&method_call].origin {
700-
ty::MethodStatic(did) => Some(did),
701-
_ => None
702-
};
703-
let is_const = match method_did {
704-
Some(did) => v.handle_const_fn_call(e, did, node_ty),
705-
None => false
699+
let is_const = match v.tcx.tables.borrow().method_map[&method_call] {
700+
ty::MethodCallee { def_id, origin: ty::MethodOrigin::Inherent, .. } => {
701+
v.handle_const_fn_call(e, def_id, node_ty)
702+
}
703+
_ => false
706704
};
707705
if !is_const {
708706
v.add_qualif(ConstQualif::NOT_CONST);

branches/auto/src/librustc/middle/dead.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
9797
span: codemap::Span) {
9898
let method_call = ty::MethodCall::expr(id);
9999
match self.tcx.tables.borrow().method_map.get(&method_call) {
100-
Some(method) => {
101-
match method.origin {
102-
ty::MethodStatic(def_id) => {
103-
match self.tcx.provided_source(def_id) {
104-
Some(p_did) => self.check_def_id(p_did),
105-
None => self.check_def_id(def_id)
106-
}
107-
}
108-
ty::MethodTypeParam(ty::MethodParam {
109-
ref trait_ref,
110-
method_num: index,
111-
..
112-
}) |
113-
ty::MethodTraitObject(ty::MethodObject {
114-
ref trait_ref,
115-
method_num: index,
116-
..
117-
}) => {
118-
let trait_item = self.tcx.trait_item(trait_ref.def_id, index);
119-
self.check_def_id(trait_item.def_id());
120-
}
121-
}
122-
}
100+
Some(method) => self.check_def_id(method.def_id),
123101
None => {
124102
self.tcx.sess.span_bug(span,
125103
"method call expression not \

0 commit comments

Comments
 (0)