Skip to content

Commit 675c272

Browse files
committed
rustc: Instantiate trait refs for automatically-derived implementations. Should fix check-fast. rs=bustage
1 parent b7872fa commit 675c272

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/rustc/metadata/encoder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
556556
}
557557
let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index);
558558

559+
debug!("encoding info for item at %s",
560+
syntax::codemap::span_to_str(item.span, ecx.tcx.sess.codemap));
561+
559562
match item.node {
560563
item_const(_, _) => {
561564
add_to_index();
@@ -738,7 +741,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Serializer,
738741
}
739742
}
740743
do opt_trait.iter() |associated_trait| {
741-
encode_trait_ref(ebml_w, ecx, *associated_trait)
744+
encode_trait_ref(ebml_w, ecx, *associated_trait);
742745
}
743746
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
744747
ebml_w.end_tag();

src/rustc/middle/typeck/collect.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,20 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
522522
region_param: rp,
523523
ty: selfty});
524524

525-
for ms_opt.each |ms| {
526-
let cms = convert_methods(ccx, *ms, rp, i_bounds);
527-
for trait_ref.each |t| {
528-
check_methods_against_trait(ccx, tps, rp, selfty, *t, cms);
525+
match ms_opt {
526+
Some(ref ms) => {
527+
let cms = convert_methods(ccx, *ms, rp, i_bounds);
528+
for trait_ref.each |t| {
529+
check_methods_against_trait(ccx, tps, rp, selfty, *t,
530+
cms);
531+
}
532+
}
533+
None => {
534+
// We still need to instantiate the trait ref here so that
535+
// metadata encoding will find the type.
536+
for trait_ref.each |trait_ref| {
537+
let _ = instantiate_trait_ref(ccx, *trait_ref, rp);
538+
}
529539
}
530540
}
531541
}

0 commit comments

Comments
 (0)