1515// makes all other generics or inline functions that it references
1616// reachable as well.
1717
18+ use hir:: TransFnAttrs ;
1819use hir:: map as hir_map;
1920use hir:: def:: Def ;
2021use hir:: def_id:: { DefId , CrateNum } ;
@@ -43,8 +44,8 @@ fn generics_require_inlining(generics: &hir::Generics) -> bool {
4344// Returns true if the given item must be inlined because it may be
4445// monomorphized or it was marked with `#[inline]`. This will only return
4546// true for functions.
46- fn item_might_be_inlined ( item : & hir:: Item ) -> bool {
47- if attr :: requests_inline ( & item . attrs ) {
47+ fn item_might_be_inlined ( item : & hir:: Item , attrs : TransFnAttrs ) -> bool {
48+ if attrs . requests_inline ( ) {
4849 return true
4950 }
5051
@@ -60,14 +61,15 @@ fn item_might_be_inlined(item: &hir::Item) -> bool {
6061fn method_might_be_inlined < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
6162 impl_item : & hir:: ImplItem ,
6263 impl_src : DefId ) -> bool {
63- if attr:: requests_inline ( & impl_item. attrs ) ||
64+ let trans_fn_attrs = tcx. trans_fn_attrs ( impl_item. hir_id . owner_def_id ( ) ) ;
65+ if trans_fn_attrs. requests_inline ( ) ||
6466 generics_require_inlining ( & impl_item. generics ) {
6567 return true
6668 }
6769 if let Some ( impl_node_id) = tcx. hir . as_local_node_id ( impl_src) {
6870 match tcx. hir . find ( impl_node_id) {
6971 Some ( hir_map:: NodeItem ( item) ) =>
70- item_might_be_inlined ( & item) ,
72+ item_might_be_inlined ( & item, trans_fn_attrs ) ,
7173 Some ( ..) | None =>
7274 span_bug ! ( impl_item. span, "impl did is not an item" )
7375 }
@@ -160,7 +162,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
160162 match self . tcx . hir . find ( node_id) {
161163 Some ( hir_map:: NodeItem ( item) ) => {
162164 match item. node {
163- hir:: ItemFn ( ..) => item_might_be_inlined ( & item) ,
165+ hir:: ItemFn ( ..) =>
166+ item_might_be_inlined ( & item, self . tcx . trans_fn_attrs ( def_id) ) ,
164167 _ => false ,
165168 }
166169 }
@@ -176,8 +179,9 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
176179 match impl_item. node {
177180 hir:: ImplItemKind :: Const ( ..) => true ,
178181 hir:: ImplItemKind :: Method ( ..) => {
182+ let attrs = self . tcx . trans_fn_attrs ( def_id) ;
179183 if generics_require_inlining ( & impl_item. generics ) ||
180- attr :: requests_inline ( & impl_item . attrs ) {
184+ attrs . requests_inline ( ) {
181185 true
182186 } else {
183187 let impl_did = self . tcx
@@ -229,7 +233,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
229233 false
230234 } ;
231235 let def_id = self . tcx . hir . local_def_id ( item. id ) ;
232- let is_extern = self . tcx . contains_extern_indicator ( def_id) ;
236+ let is_extern = self . tcx . trans_fn_attrs ( def_id) . contains_extern_indicator ( ) ;
233237 if reachable || is_extern {
234238 self . reachable_symbols . insert ( search_item) ;
235239 }
@@ -246,7 +250,8 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
246250 hir_map:: NodeItem ( item) => {
247251 match item. node {
248252 hir:: ItemFn ( .., body) => {
249- if item_might_be_inlined ( & item) {
253+ let def_id = self . tcx . hir . local_def_id ( item. id ) ;
254+ if item_might_be_inlined ( & item, self . tcx . trans_fn_attrs ( def_id) ) {
250255 self . visit_nested_body ( body) ;
251256 }
252257 }
0 commit comments