Skip to content

Commit e546fea

Browse files
Don't duplicate logic of when an Instance requests to be inlined.
1 parent 48a8d23 commit e546fea

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/librustc_trans_utils/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ pub fn requests_inline<'a, 'tcx>(
5151
// available to normal end-users.
5252
return true
5353
}
54-
attr::requests_inline(&instance.def.attrs(tcx)[..])
54+
attr::requests_inline(&instance.def.attrs(tcx)[..]) ||
55+
tcx.is_const_fn(instance.def.def_id())
5556
}
5657

5758
pub fn is_inline_instance<'a, 'tcx>(

src/librustc_trans_utils/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ extern crate rustc_data_structures;
4040
extern crate syntax;
4141
extern crate syntax_pos;
4242

43-
use rustc::ty::TyCtxt;
43+
use rustc::ty::{TyCtxt, Instance};
4444
use rustc::hir;
4545
use rustc::hir::def_id::LOCAL_CRATE;
4646
use rustc::hir::map as hir_map;
4747
use rustc::util::nodemap::NodeSet;
4848

49-
use syntax::attr;
50-
5149
pub mod common;
5250
pub mod link;
5351
pub mod collector;
@@ -77,7 +75,7 @@ pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
7775
///
7876
/// This list is later used by linkers to determine the set of symbols needed to
7977
/// be exposed from a dynamic library and it's also encoded into the metadata.
80-
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
78+
pub fn find_exported_symbols<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> NodeSet {
8179
tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| {
8280
// Next, we want to ignore some FFI functions that are not exposed from
8381
// this crate. Reachable FFI functions can be lumped into two
@@ -110,8 +108,7 @@ pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
110108
(generics.parent_types == 0 && generics.types.is_empty()) &&
111109
// Functions marked with #[inline] are only ever translated
112110
// with "internal" linkage and are never exported.
113-
!attr::requests_inline(&tcx.get_attrs(def_id)) &&
114-
!tcx.is_const_fn(def_id)
111+
!common::requests_inline(tcx, &Instance::mono(tcx, def_id))
115112
}
116113

117114
_ => false

0 commit comments

Comments
 (0)