Skip to content

Commit f1c6360

Browse files
committed
---
yaml --- r: 31589 b: refs/heads/dist-snap c: 2fe299d h: refs/heads/master i: 31587: f68bc3d v: v3
1 parent ac67b04 commit f1c6360

File tree

8 files changed

+49
-12
lines changed

8 files changed

+49
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 97452c0ca16238a2de5503aca07db26ff9e8ba63
10+
refs/heads/dist-snap: 2fe299d1a53355c9bb78b9067bd2d18bd4eb94e7
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ type ty_field = spanned<ty_field_>;
511511
#[auto_serialize]
512512
type ty_method = {ident: ident, attrs: ~[attribute],
513513
decl: fn_decl, tps: ~[ty_param], self_ty: self_ty,
514-
span: span};
514+
id: node_id, span: span};
515515

516516
#[auto_serialize]
517517
// A trait method is either required (meaning it doesn't have an

branches/dist-snap/src/libsyntax/ast_map.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ fn path_to_str(p: path) -> ~str {
3535
enum ast_node {
3636
node_item(@item, @path),
3737
node_foreign_item(@foreign_item, foreign_abi, @path),
38+
node_trait_method(@trait_method, def_id /* trait did */,
39+
@path /* path to the trait */),
3840
node_method(@method, def_id /* impl did */, @path /* path to the impl */),
3941
node_variant(variant, @item, @path),
4042
node_expr(@expr),
@@ -218,19 +220,24 @@ fn map_item(i: @item, cx: ctx, v: vt) {
218220
let (_, ms) = ast_util::split_class_items(items);
219221
// Map trait refs to their parent classes. This is
220222
// so we can find the self_ty
221-
do vec::iter(traits) |p| { cx.map.insert(p.ref_id,
222-
node_item(i, item_path));
223-
// This is so we can look up the right things when
224-
// encoding/decoding
225-
cx.map.insert(p.impl_id,
226-
node_item(i, item_path));
227-
228-
};
223+
for traits.each |p| {
224+
cx.map.insert(p.ref_id, node_item(i, item_path));
225+
// This is so we can look up the right things when
226+
// encoding/decoding
227+
cx.map.insert(p.impl_id, node_item(i, item_path));
228+
}
229229
let d_id = ast_util::local_def(i.id);
230230
let p = extend(cx, i.ident);
231231
// only need to handle methods
232232
do vec::iter(ms) |m| { map_method(d_id, p, m, cx); }
233233
}
234+
item_trait(tps, methods) {
235+
for methods.each |tm| {
236+
let id = ast_util::trait_method_to_ty_method(tm).id;
237+
let d_id = ast_util::local_def(i.id);
238+
cx.map.insert(id, node_trait_method(@tm, d_id, item_path));
239+
}
240+
}
234241
_ { }
235242
}
236243
alt i.node {
@@ -283,6 +290,11 @@ fn node_id_to_str(map: map, id: node_id) -> ~str {
283290
fmt!{"method %s in %s (id=%?)",
284291
*m.ident, path_to_str(*path), id}
285292
}
293+
some(node_trait_method(tm, impl_did, path)) {
294+
let m = ast_util::trait_method_to_ty_method(*tm);
295+
fmt!{"method %s in %s (id=%?)",
296+
*m.ident, path_to_str(*path), id}
297+
}
286298
some(node_variant(variant, def_id, path)) {
287299
fmt!{"variant %s in %s (id=%?)",
288300
*variant.node.name, path_to_str(*path), id}

branches/dist-snap/src/libsyntax/ast_util.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,19 @@ fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) {
316316
(vs, ms)
317317
}
318318

319+
// extract a ty_method from a trait_method. if the trait_method is
320+
// a default, pull out the useful fields to make a ty_method
321+
fn trait_method_to_ty_method(method: trait_method) -> ty_method {
322+
alt method {
323+
required(m) { m }
324+
provided(m) {
325+
{ident: m.ident, attrs: m.attrs,
326+
decl: m.decl, tps: m.tps, self_ty: m.self_ty,
327+
id: m.id, span: m.span}
328+
}
329+
}
330+
}
331+
319332
pure fn class_member_visibility(ci: @class_member) -> visibility {
320333
alt ci.node {
321334
instance_var(_, _, _, _, vis) { vis }

branches/dist-snap/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class parser {
291291
required({ident: ident, attrs: attrs,
292292
decl: {purity: pur with d}, tps: tps,
293293
self_ty: self_ty,
294-
span: mk_sp(lo, hi)})
294+
id: p.get_id(), span: mk_sp(lo, hi)})
295295
}
296296
token::LBRACE {
297297
debug!{"parse_trait_methods(): parsing provided method"};

branches/dist-snap/src/rustc/middle/trans/base.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
21112111
}
21122112
ast_map::node_ctor(nm, _, ct, _, pt) { (pt, nm, ct.span) }
21132113
ast_map::node_dtor(_, dtor, _, pt) {(pt, @~"drop", dtor.span)}
2114+
ast_map::node_trait_method(*) {
2115+
ccx.tcx.sess.bug(~"Can't monomorphize a trait method")
2116+
}
21142117
ast_map::node_expr(*) {
21152118
ccx.tcx.sess.bug(~"Can't monomorphize an expr")
21162119
}
@@ -2207,6 +2210,9 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id,
22072210
ast_map::node_expr(*) {
22082211
ccx.tcx.sess.bug(~"Can't monomorphize an expr")
22092212
}
2213+
ast_map::node_trait_method(*) {
2214+
ccx.tcx.sess.bug(~"Can't monomorphize a trait method")
2215+
}
22102216
ast_map::node_export(*) {
22112217
ccx.tcx.sess.bug(~"Can't monomorphize an export")
22122218
}
@@ -2418,7 +2424,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result {
24182424
return {val: slf, kind: lv_owned};
24192425
}
24202426
_ {
2421-
cx.sess().unimpl(fmt!{"unsupported def type in trans_local_def: %?",
2427+
cx.sess().unimpl(fmt!{"unsupported def type in trans_local_var: %?",
24222428
def});
24232429
}
24242430
}

branches/dist-snap/src/rustc/middle/trans/impl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res)
185185
@vec::map(*vts, |d| resolve_vtable_in_fn_ctxt(fcx, d))
186186
}
187187

188+
// Apply the typaram substitutions in the fn_ctxt to a vtable. This should
189+
// eliminate any vtable_params.
188190
fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
189191
-> typeck::vtable_origin {
190192
alt vt {

branches/dist-snap/src/rustc/middle/ty.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,10 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
27592759
ast_map::node_method(method, _, path) {
27602760
vec::append_one(*path, ast_map::path_name(method.ident))
27612761
}
2762+
ast_map::node_trait_method(trait_method, _, path) {
2763+
let method = ast_util::trait_method_to_ty_method(*trait_method);
2764+
vec::append_one(*path, ast_map::path_name(method.ident))
2765+
}
27622766

27632767
ast_map::node_variant(variant, _, path) {
27642768
vec::append_one(vec::init(*path),

0 commit comments

Comments
 (0)