if let TerminatorKind::Call {
func: Operand::Constant(ref f), .. } = terminator.kind {
if let ty::TyFnDef(callee_def_id, substs) = f.ty.sty {
- callsites.push_back(CallSite {
- callee: callee_def_id,
- substs,
- bb,
- location: terminator.source_info
- });
+ let should_inline = match self.tcx.opt_associated_item(callee_def_id) {
+ Some(item) => match item.container {
+ ty::AssociatedItemContainer::ImplContainer(_) => true,
+ ty::AssociatedItemContainer::TraitContainer(_) => false,
+ },
+ None => true
+ };
+
+ if should_inline {
+ callsites.push_back(CallSite {
+ callee: callee_def_id,
+ substs,
+ bb,
+ location: terminator.source_info
+ });
+ }
}
}
}