Skip to content

Commit 6be62bb

Browse files
committed
---
yaml --- r: 235477 b: refs/heads/stable c: 49d3a93 h: refs/heads/master i: 235475: 2917638 v: v3
1 parent fed4f6a commit 6be62bb

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
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 94f13ac376f44711106f08175241ed909578de06
32+
refs/heads/stable: 49d3a93c52e65b5b37370390dd352471c21dbaf7
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/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/stable/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)