@@ -20,7 +20,7 @@ use hir::map as hir_map;
20
20
use hir:: def:: Def ;
21
21
use hir:: def_id:: { DefId , CrateNum } ;
22
22
use rustc_data_structures:: sync:: Lrc ;
23
- use ty:: { self , TyCtxt , GenericParamDefKind } ;
23
+ use ty:: { self , TyCtxt } ;
24
24
use ty:: query:: Providers ;
25
25
use middle:: privacy;
26
26
use session:: config;
@@ -34,18 +34,6 @@ use hir::intravisit::{Visitor, NestedVisitorMap};
34
34
use hir:: itemlikevisit:: ItemLikeVisitor ;
35
35
use hir:: intravisit;
36
36
37
- // Returns true if the given set of generics implies that the item it's
38
- // associated with must be inlined.
39
- fn generics_require_inlining ( generics : & ty:: Generics ) -> bool {
40
- for param in & generics. params {
41
- match param. kind {
42
- GenericParamDefKind :: Lifetime { .. } => { }
43
- GenericParamDefKind :: Type { .. } => return true ,
44
- }
45
- }
46
- false
47
- }
48
-
49
37
// Returns true if the given item must be inlined because it may be
50
38
// monomorphized or it was marked with `#[inline]`. This will only return
51
39
// true for functions.
@@ -60,7 +48,7 @@ fn item_might_be_inlined(tcx: TyCtxt<'a, 'tcx, 'tcx>,
60
48
hir:: ItemKind :: Impl ( ..) |
61
49
hir:: ItemKind :: Fn ( ..) => {
62
50
let generics = tcx. generics_of ( tcx. hir . local_def_id ( item. id ) ) ;
63
- generics_require_inlining ( generics)
51
+ generics. requires_monomorphization ( tcx )
64
52
}
65
53
_ => false ,
66
54
}
@@ -71,7 +59,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
71
59
impl_src : DefId ) -> bool {
72
60
let codegen_fn_attrs = tcx. codegen_fn_attrs ( impl_item. hir_id . owner_def_id ( ) ) ;
73
61
let generics = tcx. generics_of ( tcx. hir . local_def_id ( impl_item. id ) ) ;
74
- if codegen_fn_attrs. requests_inline ( ) || generics_require_inlining ( generics) {
62
+ if codegen_fn_attrs. requests_inline ( ) || generics. requires_monomorphization ( tcx ) {
75
63
return true
76
64
}
77
65
if let Some ( impl_node_id) = tcx. hir . as_local_node_id ( impl_src) {
@@ -189,8 +177,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
189
177
hir:: ImplItemKind :: Method ( ..) => {
190
178
let attrs = self . tcx . codegen_fn_attrs ( def_id) ;
191
179
let generics = self . tcx . generics_of ( def_id) ;
192
- if generics_require_inlining ( & generics) ||
193
- attrs. requests_inline ( ) {
180
+ if generics. requires_monomorphization ( self . tcx ) || attrs. requests_inline ( ) {
194
181
true
195
182
} else {
196
183
let impl_did = self . tcx
@@ -203,7 +190,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
203
190
match self . tcx . hir . expect_item ( impl_node_id) . node {
204
191
hir:: ItemKind :: Impl ( ..) => {
205
192
let generics = self . tcx . generics_of ( impl_did) ;
206
- generics_require_inlining ( & generics)
193
+ generics. requires_monomorphization ( self . tcx )
207
194
}
208
195
_ => false
209
196
}
0 commit comments