parent
e8cd6cc237
commit
4f840a683a
13 changed files with 149 additions and 137 deletions
|
|
@ -15,6 +15,7 @@
|
|||
// makes all other generics or inline functions that it references
|
||||
// reachable as well.
|
||||
|
||||
use hir::TransFnAttrs;
|
||||
use hir::map as hir_map;
|
||||
use hir::def::Def;
|
||||
use hir::def_id::{DefId, CrateNum};
|
||||
|
|
@ -43,8 +44,8 @@ fn generics_require_inlining(generics: &hir::Generics) -> bool {
|
|||
// Returns true if the given item must be inlined because it may be
|
||||
// monomorphized or it was marked with `#[inline]`. This will only return
|
||||
// true for functions.
|
||||
fn item_might_be_inlined(item: &hir::Item) -> bool {
|
||||
if attr::requests_inline(&item.attrs) {
|
||||
fn item_might_be_inlined(item: &hir::Item, attrs: TransFnAttrs) -> bool {
|
||||
if attrs.requests_inline() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -60,14 +61,15 @@ fn item_might_be_inlined(item: &hir::Item) -> bool {
|
|||
fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
impl_item: &hir::ImplItem,
|
||||
impl_src: DefId) -> bool {
|
||||
if attr::requests_inline(&impl_item.attrs) ||
|
||||
let trans_fn_attrs = tcx.trans_fn_attrs(impl_item.hir_id.owner_def_id());
|
||||
if trans_fn_attrs.requests_inline() ||
|
||||
generics_require_inlining(&impl_item.generics) {
|
||||
return true
|
||||
}
|
||||
if let Some(impl_node_id) = tcx.hir.as_local_node_id(impl_src) {
|
||||
match tcx.hir.find(impl_node_id) {
|
||||
Some(hir_map::NodeItem(item)) =>
|
||||
item_might_be_inlined(&item),
|
||||
item_might_be_inlined(&item, trans_fn_attrs),
|
||||
Some(..) | None =>
|
||||
span_bug!(impl_item.span, "impl did is not an item")
|
||||
}
|
||||
|
|
@ -160,7 +162,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
match self.tcx.hir.find(node_id) {
|
||||
Some(hir_map::NodeItem(item)) => {
|
||||
match item.node {
|
||||
hir::ItemFn(..) => item_might_be_inlined(&item),
|
||||
hir::ItemFn(..) =>
|
||||
item_might_be_inlined(&item, self.tcx.trans_fn_attrs(def_id)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
@ -176,8 +179,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
match impl_item.node {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(..) => {
|
||||
let attrs = self.tcx.trans_fn_attrs(def_id);
|
||||
if generics_require_inlining(&impl_item.generics) ||
|
||||
attr::requests_inline(&impl_item.attrs) {
|
||||
attrs.requests_inline() {
|
||||
true
|
||||
} else {
|
||||
let impl_did = self.tcx
|
||||
|
|
@ -246,7 +250,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
hir_map::NodeItem(item) => {
|
||||
match item.node {
|
||||
hir::ItemFn(.., body) => {
|
||||
if item_might_be_inlined(&item) {
|
||||
let def_id = self.tcx.hir.local_def_id(item.id);
|
||||
if item_might_be_inlined(&item, self.tcx.trans_fn_attrs(def_id)) {
|
||||
self.visit_nested_body(body);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue