mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-15 13:36:49 +00:00
Don't duplicate logic of when an Instance requests to be inlined.
This commit is contained in:
parent
48a8d23b97
commit
e546fea0a1
@ -51,7 +51,8 @@ pub fn requests_inline<'a, 'tcx>(
|
||||
// available to normal end-users.
|
||||
return true
|
||||
}
|
||||
attr::requests_inline(&instance.def.attrs(tcx)[..])
|
||||
attr::requests_inline(&instance.def.attrs(tcx)[..]) ||
|
||||
tcx.is_const_fn(instance.def.def_id())
|
||||
}
|
||||
|
||||
pub fn is_inline_instance<'a, 'tcx>(
|
||||
|
@ -40,14 +40,12 @@ extern crate rustc_data_structures;
|
||||
extern crate syntax;
|
||||
extern crate syntax_pos;
|
||||
|
||||
use rustc::ty::TyCtxt;
|
||||
use rustc::ty::{TyCtxt, Instance};
|
||||
use rustc::hir;
|
||||
use rustc::hir::def_id::LOCAL_CRATE;
|
||||
use rustc::hir::map as hir_map;
|
||||
use rustc::util::nodemap::NodeSet;
|
||||
|
||||
use syntax::attr;
|
||||
|
||||
pub mod common;
|
||||
pub mod link;
|
||||
pub mod collector;
|
||||
@ -77,7 +75,7 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
|
||||
///
|
||||
/// This list is later used by linkers to determine the set of symbols needed to
|
||||
/// be exposed from a dynamic library and it's also encoded into the metadata.
|
||||
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
|
||||
pub fn find_exported_symbols<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> NodeSet {
|
||||
tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| {
|
||||
// Next, we want to ignore some FFI functions that are not exposed from
|
||||
// this crate. Reachable FFI functions can be lumped into two
|
||||
@ -110,8 +108,7 @@ pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
|
||||
(generics.parent_types == 0 && generics.types.is_empty()) &&
|
||||
// Functions marked with #[inline] are only ever translated
|
||||
// with "internal" linkage and are never exported.
|
||||
!attr::requests_inline(&tcx.get_attrs(def_id)) &&
|
||||
!tcx.is_const_fn(def_id)
|
||||
!common::requests_inline(tcx, &Instance::mono(tcx, def_id))
|
||||
}
|
||||
|
||||
_ => false
|
||||
|
Loading…
Reference in New Issue
Block a user