@@ -21,7 +21,7 @@ use session::session;
21
21
use syntax:: attr;
22
22
use back:: { link, abi, upcall} ;
23
23
use syntax:: { ast, ast_util, codemap, ast_map} ;
24
- use ast_util:: { local_def, path_to_ident} ;
24
+ use ast_util:: { def_id_of_def , local_def, path_to_ident} ;
25
25
use syntax:: visit;
26
26
use syntax:: codemap:: span;
27
27
use syntax:: print:: pprust:: { expr_to_str, stmt_to_str, path_to_str} ;
@@ -1847,8 +1847,33 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
1847
1847
}
1848
1848
}
1849
1849
}
1850
- ast:: item_impl( tps, _ , _, ms) => {
1850
+ ast:: item_impl( tps, trait_refs , _, ms) => {
1851
1851
meth:: trans_impl ( ccx, * path, item. ident , ms, tps) ;
1852
+
1853
+ // Translate any methods that have provided implementations.
1854
+ for trait_refs. each |trait_ref_ptr| {
1855
+ let trait_def = ccx. tcx . def_map . get ( trait_ref_ptr. ref_id ) ;
1856
+
1857
+ // XXX: Cross-crate default methods.
1858
+ match ccx. tcx . items . get ( def_id_of_def ( trait_def) . node ) {
1859
+ ast_map:: node_item( trait_item, _) => {
1860
+ match trait_item. node {
1861
+ ast:: item_trait( tps, _, trait_methods) => {
1862
+ trans_trait ( ccx, tps, trait_methods, path,
1863
+ item. ident ) ;
1864
+ }
1865
+ _ => {
1866
+ ccx. tcx . sess . impossible_case ( item. span ,
1867
+ ~"trait item not a \
1868
+ trait ") ;
1869
+ }
1870
+ }
1871
+ }
1872
+ _ => {
1873
+ ccx. tcx . sess . impossible_case ( item. span , ~"no trait item") ;
1874
+ }
1875
+ }
1876
+ }
1852
1877
}
1853
1878
ast:: item_mod( m) => {
1854
1879
trans_mod ( ccx, m) ;
@@ -1873,9 +1898,6 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
1873
1898
ast:: item_class( struct_def, tps) => {
1874
1899
trans_struct_def ( ccx, struct_def, tps, path, item. ident , item. id ) ;
1875
1900
}
1876
- ast:: item_trait( tps, _, trait_methods) => {
1877
- trans_trait ( ccx, tps, trait_methods, path, item. ident ) ;
1878
- }
1879
1901
_ => { /* fall through */ }
1880
1902
}
1881
1903
}
0 commit comments