Skip to content

Commit 07d0b27

Browse files
committed
---
yaml --- r: 37555 b: refs/heads/try c: 32ad4ae h: refs/heads/master i: 37553: 75d1ad5 37551: cf6a305 v: v3
1 parent e9c64ae commit 07d0b27

30 files changed

+336
-273
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5-
refs/heads/try: 3e14ada4f6782f1379abe498b2b2d9681f489e26
5+
refs/heads/try: 32ad4ae4cde68fed1b132be79bc9068b020d270b
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278

branches/try/src/librustc/front/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod,
8383
fn fold_item_underscore(cx: ctxt, item: ast::item_,
8484
fld: fold::ast_fold) -> ast::item_ {
8585
let item = match item {
86-
ast::item_impl(a, b, c, Some(methods)) => {
86+
ast::item_impl(a, b, c, methods) => {
8787
let methods = methods.filter(|m| method_in_cfg(cx, *m) );
88-
ast::item_impl(a, b, c, Some(methods))
88+
ast::item_impl(a, b, c, methods)
8989
}
9090
ast::item_trait(a, b, ref methods) => {
9191
let methods = methods.filter(|m| trait_method_in_cfg(cx, m) );

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
715715
encode_index(ebml_w, bkts, write_int);
716716
ebml_w.end_tag();
717717
}
718-
item_impl(tps, opt_trait, ty, methods_opt) => {
718+
item_impl(tps, opt_trait, ty, methods) => {
719719
add_to_index();
720720
ebml_w.start_tag(tag_items_data_item);
721721
encode_def_id(ebml_w, local_def(item.id));
@@ -732,13 +732,11 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
732732
}
733733
_ => {}
734734
}
735-
for methods_opt.each |methods| {
736-
for methods.each |m| {
737-
ebml_w.start_tag(tag_item_impl_method);
738-
let method_def_id = local_def(m.id);
739-
ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id)));
740-
ebml_w.end_tag();
741-
}
735+
for methods.each |m| {
736+
ebml_w.start_tag(tag_item_impl_method);
737+
let method_def_id = local_def(m.id);
738+
ebml_w.writer.write(str::to_bytes(def_to_str(method_def_id)));
739+
ebml_w.end_tag();
742740
}
743741
do opt_trait.iter() |associated_trait| {
744742
encode_trait_ref(ebml_w, ecx, *associated_trait);
@@ -748,13 +746,11 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
748746

749747
let impl_path = vec::append_one(path,
750748
ast_map::path_name(item.ident));
751-
for methods_opt.each |methods| {
752-
for methods.each |m| {
753-
index.push({val: m.id, pos: ebml_w.writer.tell()});
754-
encode_info_for_method(ecx, ebml_w, impl_path,
755-
should_inline(m.attrs), item.id, *m,
756-
vec::append(tps, m.tps));
757-
}
749+
for methods.each |m| {
750+
index.push({val: m.id, pos: ebml_w.writer.tell()});
751+
encode_info_for_method(ecx, ebml_w, impl_path,
752+
should_inline(m.attrs), item.id, *m,
753+
vec::append(tps, m.tps));
758754
}
759755
}
760756
item_trait(tps, traits, ms) => {

branches/try/src/librustc/middle/resolve.rs

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ impl Resolver {
12231223
visit_item(item, new_parent, visitor);
12241224
}
12251225

1226-
item_impl(_, trait_ref_opt, ty, methods_opt) => {
1226+
item_impl(_, trait_ref_opt, ty, methods) => {
12271227
// If this implements an anonymous trait and it has static
12281228
// methods, then add all the static methods within to a new
12291229
// module, if the type was defined within this module.
@@ -1234,12 +1234,10 @@ impl Resolver {
12341234

12351235
// Bail out early if there are no static methods.
12361236
let mut has_static_methods = false;
1237-
for methods_opt.each |methods| {
1238-
for methods.each |method| {
1239-
match method.self_ty.node {
1240-
sty_static => has_static_methods = true,
1241-
_ => {}
1242-
}
1237+
for methods.each |method| {
1238+
match method.self_ty.node {
1239+
sty_static => has_static_methods = true,
1240+
_ => {}
12431241
}
12441242
}
12451243

@@ -1266,26 +1264,24 @@ impl Resolver {
12661264
name_bindings.get_module());
12671265

12681266
// For each static method...
1269-
for methods_opt.each |methods| {
1270-
for methods.each |method| {
1271-
match method.self_ty.node {
1272-
sty_static => {
1273-
// Add the static method to the
1274-
// module.
1275-
let ident = method.ident;
1276-
let (method_name_bindings, _) =
1277-
self.add_child(
1278-
ident,
1279-
new_parent,
1280-
ForbidDuplicateValues,
1281-
method.span);
1282-
let def = def_fn(local_def(method.id),
1283-
method.purity);
1284-
method_name_bindings.define_value(
1285-
Public, def, method.span);
1286-
}
1287-
_ => {}
1267+
for methods.each |method| {
1268+
match method.self_ty.node {
1269+
sty_static => {
1270+
// Add the static method to the
1271+
// module.
1272+
let ident = method.ident;
1273+
let (method_name_bindings, _) =
1274+
self.add_child(
1275+
ident,
1276+
new_parent,
1277+
ForbidDuplicateValues,
1278+
method.span);
1279+
let def = def_fn(local_def(method.id),
1280+
method.purity);
1281+
method_name_bindings.define_value(
1282+
Public, def, method.span);
12881283
}
1284+
_ => {}
12891285
}
12901286
}
12911287
}
@@ -3553,14 +3549,16 @@ impl Resolver {
35533549
}
35543550
}
35553551

3556-
item_impl(type_parameters, implemented_traits, self_type,
3557-
methods_opt) => {
3552+
item_impl(type_parameters,
3553+
implemented_traits,
3554+
self_type,
3555+
methods) => {
35583556
self.resolve_implementation(item.id,
35593557
item.span,
35603558
type_parameters,
35613559
implemented_traits,
35623560
self_type,
3563-
methods_opt,
3561+
methods,
35643562
visitor);
35653563
}
35663564

@@ -3988,7 +3986,7 @@ impl Resolver {
39883986
type_parameters: ~[ty_param],
39893987
opt_trait_reference: Option<@trait_ref>,
39903988
self_type: @Ty,
3991-
opt_methods: Option<~[@method]>,
3989+
methods: ~[@method],
39923990
visitor: ResolveVisitor) {
39933991
// If applicable, create a rib for the type parameters.
39943992
let outer_type_parameter_count = type_parameters.len();
@@ -4027,16 +4025,15 @@ impl Resolver {
40274025
// Resolve the self type.
40284026
self.resolve_type(self_type, visitor);
40294027

4030-
for opt_methods.each |methods| {
4031-
for methods.each |method| {
4032-
// We also need a new scope for the method-specific
4033-
// type parameters.
4034-
self.resolve_method(MethodRibKind(
4035-
id,
4036-
Provided(method.id)),
4037-
*method,
4038-
outer_type_parameter_count,
4039-
visitor);
4028+
for methods.each |method| {
4029+
// We also need a new scope for the method-specific
4030+
// type parameters.
4031+
self.resolve_method(MethodRibKind(
4032+
id,
4033+
Provided(method.id)),
4034+
*method,
4035+
outer_type_parameter_count,
4036+
visitor);
40404037
/*
40414038
let borrowed_type_parameters = &method.tps;
40424039
self.resolve_function(MethodRibKind(
@@ -4053,7 +4050,6 @@ impl Resolver {
40534050
NoCaptureClause,
40544051
visitor);
40554052
*/
4056-
}
40574053
}
40584054

40594055
// Restore the original trait references.

branches/try/src/librustc/middle/trans/base.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,17 +1854,13 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
18541854
}
18551855
}
18561856
}
1857-
ast::item_impl(tps, _, _, ms_opt) => {
1858-
match ms_opt {
1859-
None => {
1860-
deriving::trans_deriving_impl(ccx, *path, item.ident, tps,
1861-
item.id);
1862-
}
1863-
Some(ms) => {
1864-
meth::trans_impl(ccx, *path, item.ident, ms, tps, None,
1865-
item.id);
1866-
}
1867-
}
1857+
ast::item_impl(tps, _, _, ms) => {
1858+
// This call will do nothing if there are no derivable methods.
1859+
deriving::trans_deriving_impl(ccx, *path, item.ident, tps,
1860+
item.id);
1861+
1862+
meth::trans_impl(ccx, *path, item.ident, ms, tps, None,
1863+
item.id);
18681864
}
18691865
ast::item_mod(m) => {
18701866
trans_mod(ccx, m);

branches/try/src/librustc/middle/trans/deriving.rs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,37 +53,43 @@ impl DerivingKind {
5353
}
5454
}
5555

56-
/// The main "translation" pass for automatically-derived impls. Generates
57-
/// code for monomorphic methods only. Other methods will be generated when
58-
/// they are invoked with specific type parameters; see
56+
/// The main "translation" pass for the automatically-derived methods in
57+
/// an impl. Generates code for monomorphic methods only. Other methods will
58+
/// be generated when they are invoked with specific type parameters; see
5959
/// `trans::base::lval_static_fn()` or `trans::base::monomorphic_fn()`.
60-
pub fn trans_deriving_impl(ccx: @crate_ctxt, _path: path, _name: ident,
61-
tps: ~[ty_param], id: node_id) {
60+
pub fn trans_deriving_impl(ccx: @crate_ctxt,
61+
_path: path,
62+
_name: ident,
63+
tps: ~[ty_param],
64+
id: node_id) {
6265
let _icx = ccx.insn_ctxt("deriving::trans_deriving_impl");
6366
if tps.len() > 0 { return; }
6467

6568
let impl_def_id = local_def(id);
6669
let self_ty = ty::lookup_item_type(ccx.tcx, impl_def_id);
67-
let method_dids = ccx.tcx.automatically_derived_methods_for_impl.get(
68-
impl_def_id);
69-
70-
for method_dids.each |method_did| {
71-
let kind = DerivingKind::of_item(ccx, *method_did);
72-
let llfn = get_item_val(ccx, method_did.node);
73-
match ty::get(self_ty.ty).sty {
74-
ty::ty_class(*) => {
75-
trans_deriving_struct_method(ccx, llfn, impl_def_id,
76-
self_ty.ty, kind);
77-
}
78-
ty::ty_enum(*) => {
79-
trans_deriving_enum_method(ccx, llfn, impl_def_id,
80-
self_ty.ty, kind);
81-
}
82-
_ => {
83-
ccx.tcx.sess.bug(~"translation of non-struct deriving \
84-
method");
70+
71+
match ccx.tcx.automatically_derived_methods_for_impl.find(impl_def_id) {
72+
Some(copy method_dids) => {
73+
for method_dids.each |method_did| {
74+
let kind = DerivingKind::of_item(ccx, *method_did);
75+
let llfn = get_item_val(ccx, method_did.node);
76+
match ty::get(self_ty.ty).sty {
77+
ty::ty_class(*) => {
78+
trans_deriving_struct_method(ccx, llfn, impl_def_id,
79+
self_ty.ty, kind);
80+
}
81+
ty::ty_enum(*) => {
82+
trans_deriving_enum_method(ccx, llfn, impl_def_id,
83+
self_ty.ty, kind);
84+
}
85+
_ => {
86+
ccx.tcx.sess.bug(~"translation of non-struct \
87+
deriving method");
88+
}
89+
}
8590
}
8691
}
92+
None => {} // Nothing to do.
8793
}
8894
}
8995

branches/try/src/librustc/middle/trans/meth.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,7 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
306306
name: ast::ident) -> ast::def_id {
307307
if impl_id.crate == ast::local_crate {
308308
match ccx.tcx.items.get(impl_id.node) {
309-
ast_map::node_item(@{node: ast::item_impl(_, _, _, Some(ms)), _},
310-
_) => {
309+
ast_map::node_item(@{node: ast::item_impl(_, _, _, ms), _}, _) => {
311310
method_from_methods(ms, name)
312311
}
313312
ast_map::node_item(@{node:

branches/try/src/librustc/middle/trans/reachable.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,12 @@ fn traverse_public_item(cx: ctx, item: @item) {
9090
traverse_inline_body(cx, blk);
9191
}
9292
}
93-
item_impl(tps, _, _, ms_opt) => {
94-
for ms_opt.each |ms| {
95-
for vec::each(*ms) |m| {
96-
if tps.len() > 0u || m.tps.len() > 0u ||
97-
attr::find_inline_attr(m.attrs) != attr::ia_none {
98-
cx.rmap.insert(m.id, ());
99-
traverse_inline_body(cx, m.body);
100-
}
93+
item_impl(tps, _, _, ms) => {
94+
for vec::each(ms) |m| {
95+
if tps.len() > 0u || m.tps.len() > 0u ||
96+
attr::find_inline_attr(m.attrs) != attr::ia_none {
97+
cx.rmap.insert(m.id, ());
98+
traverse_inline_body(cx, m.body);
10199
}
102100
}
103101
}

branches/try/src/librustc/middle/typeck/check.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,13 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
498498
ast::item_fn(decl, _, _, body) => {
499499
check_bare_fn(ccx, decl, body, it.id, None);
500500
}
501-
ast::item_impl(_, _, ty, ms_opt) => {
501+
ast::item_impl(_, _, ty, ms) => {
502502
let rp = ccx.tcx.region_paramd_items.find(it.id);
503503
debug!("item_impl %s with id %d rp %?",
504504
ccx.tcx.sess.str_of(it.ident), it.id, rp);
505505
let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty);
506-
for ms_opt.each |ms| {
507-
for ms.each |m| {
508-
check_method(ccx, *m, self_ty, local_def(it.id));
509-
}
506+
for ms.each |m| {
507+
check_method(ccx, *m, self_ty, local_def(it.id));
510508
}
511509
}
512510
ast::item_trait(_, _, trait_methods) => {

0 commit comments

Comments
 (0)