Skip to content

Commit aad6742

Browse files
committed
---
yaml --- r: 31590 b: refs/heads/dist-snap c: 65e0e30 h: refs/heads/master v: v3
1 parent f1c6360 commit aad6742

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
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: 2fe299d1a53355c9bb78b9067bd2d18bd4eb94e7
10+
refs/heads/dist-snap: 65e0e30e59351aed899adbb20cbd07ae98f213d3
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,18 @@ fn trait_method_to_ty_method(method: trait_method) -> ty_method {
329329
}
330330
}
331331

332+
fn split_trait_methods(trait_methods: ~[trait_method])
333+
-> (~[ty_method], ~[@method]) {
334+
let mut reqd = ~[], provd = ~[];
335+
for trait_methods.each |trt_method| {
336+
alt trt_method {
337+
required(tm) { vec::push(reqd, tm); }
338+
provided(m) { vec::push(provd, m); }
339+
}
340+
};
341+
(reqd, provd)
342+
}
343+
332344
pure fn class_member_visibility(ci: @class_member) -> visibility {
333345
alt ci.node {
334346
instance_var(_, _, _, _, vis) { vis }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import syntax::{ast, ast_util, ast_map};
4343
import ast::spanned;
4444
import ast::{required, provided};
4545
import syntax::ast_map::node_id_to_str;
46-
import syntax::ast_util::{local_def, respan, split_class_items};
46+
import syntax::ast_util::{local_def, respan, split_class_items,
47+
split_trait_methods};
4748
import syntax::visit;
4849
import metadata::csearch;
4950
import driver::session::session;

branches/dist-snap/src/rustc/middle/typeck/collect.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,22 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
339339
check_methods_against_trait(ccx, tps, rp, selfty, t, cms);
340340
}
341341
}
342-
ast::item_trait(*) {
342+
ast::item_trait(tps, trait_methods) {
343343
let tpt = ty_of_item(ccx, it);
344344
debug!{"item_trait(it.id=%d, tpt.ty=%s)",
345345
it.id, ty_to_str(tcx, tpt.ty)};
346346
write_ty_to_tcx(tcx, it.id, tpt.ty);
347347
ensure_trait_methods(ccx, it.id);
348+
349+
let (_, provided_methods) = split_trait_methods(trait_methods);
350+
let selfty = ty::mk_self(tcx);
351+
let {bounds, _} = mk_substs(ccx, tps, rp);
352+
let _cms = convert_methods(ccx, provided_methods, rp, bounds, selfty);
353+
// FIXME (#2616): something like this, when we start having
354+
// trait inheritance?
355+
// for trt.each |t| {
356+
// check_methods_against_trait(ccx, tps, rp, selfty, t, cms);
357+
// }
348358
}
349359
ast::item_class(tps, traits, members, m_ctor, m_dtor) {
350360
// Write the class type

0 commit comments

Comments
 (0)