Skip to content

Commit 784e431

Browse files
committed
ugly, but works!
1 parent b413596 commit 784e431

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/librustc_mir/transform/inline.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,22 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
8888
if let TerminatorKind::Call {
8989
func: Operand::Constant(ref f), .. } = terminator.kind {
9090
if let ty::TyFnDef(callee_def_id, substs) = f.ty.sty {
91-
callsites.push_back(CallSite {
92-
callee: callee_def_id,
93-
substs,
94-
bb,
95-
location: terminator.source_info
96-
});
91+
let should_inline = match self.tcx.opt_associated_item(callee_def_id) {
92+
Some(item) => match item.container {
93+
ty::AssociatedItemContainer::ImplContainer(_) => true,
94+
ty::AssociatedItemContainer::TraitContainer(_) => false,
95+
},
96+
None => true
97+
};
98+
99+
if should_inline {
100+
callsites.push_back(CallSite {
101+
callee: callee_def_id,
102+
substs,
103+
bb,
104+
location: terminator.source_info
105+
});
106+
}
97107
}
98108
}
99109
}

0 commit comments

Comments
 (0)