// makes all other generics or inline functions that it references
// reachable as well.
-use rustc::hir::map::Map;
-use rustc::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
-use rustc::middle::privacy;
-use rustc::session::config;
-use rustc::ty::query::Providers;
-use rustc::ty::{self, TyCtxt};
use rustc_data_structures::fx::FxHashSet;
-use rustc_data_structures::sync::Lrc;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::LOCAL_CRATE;
-use rustc_hir::def_id::{CrateNum, DefId};
-use rustc_hir::intravisit;
-use rustc_hir::intravisit::{NestedVisitorMap, Visitor};
+use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
+use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::{HirIdSet, Node};
+use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
+use rustc_middle::middle::privacy;
+use rustc_middle::ty::query::Providers;
+use rustc_middle::ty::{self, TyCtxt};
+use rustc_session::config;
use rustc_target::spec::abi::Abi;
// Returns true if the given item must be inlined because it may be
}
match item.kind {
- hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => {
- return true;
- }
+ hir::ItemKind::Fn(ref sig, ..) if sig.header.is_const() => true,
hir::ItemKind::Impl { .. } | hir::ItemKind::Fn(..) => {
let generics = tcx.generics_of(tcx.hir().local_def_id(item.hir_id));
generics.requires_monomorphization(tcx)
fn method_might_be_inlined(
tcx: TyCtxt<'_>,
impl_item: &hir::ImplItem<'_>,
- impl_src: DefId,
+ impl_src: LocalDefId,
) -> bool {
- let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
+ let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner.to_def_id());
let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.hir_id));
if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
return true;
}
- if let hir::ImplItemKind::Method(method_sig, _) = &impl_item.kind {
+ if let hir::ImplItemKind::Fn(method_sig, _) = &impl_item.kind {
if method_sig.header.is_const() {
return true;
}
}
- if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_src) {
+ if let Some(impl_hir_id) = tcx.hir().as_local_hir_id(impl_src.to_def_id()) {
match tcx.hir().find(impl_hir_id) {
Some(Node::Item(item)) => item_might_be_inlined(tcx, &item, codegen_fn_attrs),
Some(..) | None => span_bug!(impl_item.span, "impl did is not an item"),
}
impl<'a, 'tcx> Visitor<'tcx> for ReachableContext<'a, 'tcx> {
- type Map = Map<'tcx>;
+ type Map = intravisit::ErasedMap<'tcx>;
- fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}
// If this path leads to a constant, then we need to
// recurse into the constant to continue finding
// items that are reachable.
- Res::Def(DefKind::Const, _) | Res::Def(DefKind::AssocConst, _) => {
+ Res::Def(DefKind::Const | DefKind::AssocConst, _) => {
self.worklist.push(hir_id);
}
},
Some(Node::TraitItem(trait_method)) => match trait_method.kind {
hir::TraitItemKind::Const(_, ref default) => default.is_some(),
- hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
- hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_))
+ hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(_)) => true,
+ hir::TraitItemKind::Fn(_, hir::TraitFn::Required(_))
| hir::TraitItemKind::Type(..) => false,
},
Some(Node::ImplItem(impl_item)) => {
match impl_item.kind {
hir::ImplItemKind::Const(..) => true,
- hir::ImplItemKind::Method(..) => {
+ hir::ImplItemKind::Fn(..) => {
let attrs = self.tcx.codegen_fn_attrs(def_id);
let generics = self.tcx.generics_of(def_id);
if generics.requires_monomorphization(self.tcx) || attrs.requests_inline() {
true
} else {
- let impl_did = self.tcx.hir().get_parent_did(hir_id);
+ let impl_did = self.tcx.hir().get_parent_did(hir_id).to_def_id();
// Check the impl. If the generics on the self
// type of the impl require inlining, this method
// does too.
Node::TraitItem(trait_method) => {
match trait_method.kind {
hir::TraitItemKind::Const(_, None)
- | hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) => {
+ | hir::TraitItemKind::Fn(_, hir::TraitFn::Required(_)) => {
// Keep going, nothing to get exported
}
hir::TraitItemKind::Const(_, Some(body_id))
- | hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)) => {
+ | hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(body_id)) => {
self.visit_nested_body(body_id);
}
hir::TraitItemKind::Type(..) => {}
hir::ImplItemKind::Const(_, body) => {
self.visit_nested_body(body);
}
- hir::ImplItemKind::Method(_, body) => {
+ hir::ImplItemKind::Fn(_, body) => {
let did = self.tcx.hir().get_parent_did(search_item);
if method_might_be_inlined(self.tcx, impl_item, did) {
self.visit_nested_body(body)
}
}
-fn reachable_set(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Lrc<HirIdSet> {
+fn reachable_set<'tcx>(tcx: TyCtxt<'tcx>, crate_num: CrateNum) -> &'tcx HirIdSet {
debug_assert!(crate_num == LOCAL_CRATE);
let access_levels = &tcx.privacy_access_levels(LOCAL_CRATE);
debug!("Inline reachability shows: {:?}", reachable_context.reachable_symbols);
// Return the set of reachable symbols.
- Lrc::new(reachable_context.reachable_symbols)
+ tcx.arena.alloc(reachable_context.reachable_symbols)
}
pub fn provide(providers: &mut Providers<'_>) {