ugly, but works!

This commit is contained in:
Douglas Campos 2017-09-06 23:03:41 -04:00
parent b413596da6
commit 784e4316eb

View file

@ -88,12 +88,22 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> {
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
});
}
}
}
}