Skip to content

Commit ef374f2

Browse files
committed
---
yaml --- r: 23202 b: refs/heads/master c: fb05f57 h: refs/heads/master v: v3
1 parent c1dc932 commit ef374f2

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 62a9e16cb20b070dba25fed585a14f9e3a62ac3b
2+
refs/heads/master: fb05f578817cd27124eaff2b202f4c1b56a7cb16
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,6 @@ fn print_block_unclosed(s: ps, blk: ast::blk) {
838838
false);
839839
}
840840
841-
fn print_block_unclosed_indent(s: ps, blk: ast::blk, indented: uint) {
842-
print_possibly_embedded_block_(s, blk, block_normal, indented, ~[],
843-
false);
844-
}
845-
846841
fn print_block_with_attrs(s: ps, blk: ast::blk, attrs: ~[ast::attribute]) {
847842
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs,
848843
true);
@@ -1183,16 +1178,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
11831178
assert arm.body.node.rules == ast::default_blk;
11841179
match arm.body.node.expr {
11851180
some(expr) => {
1186-
match expr.node {
1187-
ast::expr_block(blk) => {
1188-
// the block will close the pattern's ibox
1189-
print_block_unclosed_indent(s, blk, alt_indent_unit);
1190-
}
1191-
_ => {
1192-
end(s); // close the ibox for the pattern
1193-
print_expr(s, expr);
1194-
}
1195-
}
1181+
end(s); // close the ibox for the pattern
1182+
print_expr(s, expr);
11961183
if !expr_is_simple_block(expr)
11971184
&& i < len - 1 {
11981185
word(s.s, ~",");

trunk/src/rustc/middle/trans/base.rs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5023,6 +5023,9 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
50235023
ast::item_class(struct_def, tps) => {
50245024
trans_struct_def(ccx, struct_def, tps, path, item.ident, item.id);
50255025
}
5026+
ast::item_trait(tps, _, trait_methods) => {
5027+
trans_trait(ccx, tps, trait_methods, path, item.ident);
5028+
}
50265029
_ => {/* fall through */ }
50275030
}
50285031
}
@@ -5051,6 +5054,14 @@ fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
50515054
impl::trans_impl(ccx, *path, ident, ms, tps);
50525055
}
50535056

5057+
fn trans_trait(ccx: @crate_ctxt, tps: ~[ast::ty_param],
5058+
trait_methods: ~[ast::trait_method],
5059+
path: @ast_map::path, ident: ast::ident) {
5060+
// Translate any methods that have provided implementations
5061+
let (_, provided_methods) = ast_util::split_trait_methods(trait_methods);
5062+
impl::trans_impl(ccx, *path, ident, provided_methods, tps);
5063+
}
5064+
50545065
// Translate a module. Doing this amounts to translating the items in the
50555066
// module; there ends up being no artifact (aside from linkage names) of
50565067
// separate modules in the compiled program. That's because modules exist
@@ -5275,28 +5286,14 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
52755286
get_item_val()");
52765287
}
52775288
ast::provided(m) => {
5278-
// FIXME (#2794): Default methods currently compiling but not
5279-
// linking successfully; not sure if this is correct. It's
5280-
// just copypasta from the node_method case.
52815289
exprt = true;
5282-
let mty = ty::node_id_to_type(ccx.tcx, id);
5283-
let pth =
5284-
vec::append(*pth, ~[path_name(@ccx.names(~"meth")),
5285-
path_name(m.ident)]);
5286-
let llfn = register_fn_full(ccx, m.span, pth, id, mty);
5287-
set_inline_hint_if_appr(m.attrs, llfn);
5288-
llfn
5290+
trans_method(ccx, id, pth, m)
52895291
}
52905292
}
52915293
}
5292-
ast_map::node_method(m, impl_id, pth) => {
5294+
ast_map::node_method(m, _, pth) => {
52935295
exprt = true;
5294-
let mty = ty::node_id_to_type(ccx.tcx, id);
5295-
let pth = vec::append(*pth, ~[path_name(@ccx.names(~"meth")),
5296-
path_name(m.ident)]);
5297-
let llfn = register_fn_full(ccx, m.span, pth, id, mty);
5298-
set_inline_hint_if_appr(m.attrs, llfn);
5299-
llfn
5296+
trans_method(ccx, id, pth, m)
53005297
}
53015298
ast_map::node_foreign_item(ni, _, pth) => {
53025299
exprt = true;
@@ -5336,7 +5333,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
53365333
assert args.len() != 0u;
53375334
let pth = vec::append(*pth,
53385335
~[path_name(enm.ident),
5339-
path_name(v.node.name)]);
5336+
path_name(v.node.name)]);
53405337
llfn = match check enm.node {
53415338
ast::item_enum(_, _) => {
53425339
register_fn(ccx, v.span, pth, id)
@@ -5366,6 +5363,16 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
53665363
}
53675364
}
53685365

5366+
fn trans_method(ccx: @crate_ctxt, id: ast::node_id, pth: @ast_map::path,
5367+
m: @ast::method) -> ValueRef {
5368+
let mty = ty::node_id_to_type(ccx.tcx, id);
5369+
let pth = vec::append(*pth, ~[path_name(@ccx.names(~"meth")),
5370+
path_name(m.ident)]);
5371+
let llfn = register_fn_full(ccx, m.span, pth, id, mty);
5372+
set_inline_hint_if_appr(m.attrs, llfn);
5373+
llfn
5374+
}
5375+
53695376
// The constant translation pass.
53705377
fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
53715378
let _icx = ccx.insn_ctxt(~"trans_constant");

trunk/src/test/run-pass/traits-default-method-trivial.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//xfail-test
2-
31
trait Cat {
42
fn meow() -> bool;
53
fn scratch() -> bool;

0 commit comments

Comments
 (0)