Skip to content

Commit 7906d95

Browse files
committed
---
yaml --- r: 223894 b: refs/heads/beta c: 49d3a93 h: refs/heads/master v: v3
1 parent 1e4733e commit 7906d95

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 94f13ac376f44711106f08175241ed909578de06
26+
refs/heads/beta: 49d3a93c52e65b5b37370390dd352471c21dbaf7
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc/ast_map/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,13 @@ impl<'ast> Map<'ast> {
411411
}
412412
}
413413

414+
pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem {
415+
match self.find(id) {
416+
Some(NodeTraitItem(item)) => item,
417+
_ => panic!("expected trait item, found {}", self.node_to_string(id))
418+
}
419+
}
420+
414421
pub fn expect_struct(&self, id: NodeId) -> &'ast StructDef {
415422
match self.find(id) {
416423
Some(NodeItem(i)) => {

branches/beta/src/librustc_trans/save/mod.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -548,13 +548,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
548548
let ti = self.tcx.impl_or_trait_item(decl_id);
549549
match provenence {
550550
def::FromTrait(def_id) => {
551-
Some(self.tcx.trait_items(def_id)
552-
.iter()
553-
.find(|mr| {
554-
mr.name() == ti.name()
555-
})
556-
.unwrap()
557-
.def_id())
551+
self.tcx.trait_items(def_id)
552+
.iter()
553+
.find(|mr| {
554+
mr.name() == ti.name() && self.trait_method_has_body(mr)
555+
})
556+
.map(|mr| mr.def_id())
558557
}
559558
def::FromImpl(def_id) => {
560559
let impl_items = self.tcx.impl_items.borrow();
@@ -594,6 +593,20 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
594593
}
595594
}
596595

596+
fn trait_method_has_body(&self, mr: &ty::ImplOrTraitItem) -> bool {
597+
let def_id = mr.def_id();
598+
if def_id.krate != ast::LOCAL_CRATE {
599+
return false;
600+
}
601+
602+
let trait_item = self.tcx.map.expect_trait_item(def_id.node);
603+
if let ast::TraitItem_::MethodTraitItem(_, Some(_)) = trait_item.node {
604+
true
605+
} else {
606+
false
607+
}
608+
}
609+
597610
pub fn get_field_ref_data(&self,
598611
field_ref: &ast::Field,
599612
struct_id: DefId,

0 commit comments

Comments
 (0)