@@ -17,7 +17,6 @@ use rustc::ty::subst::{Subst, Substs};
17
17
use rustc:: ty:: { self , Ty , TypeFoldable , TyCtxt } ;
18
18
use attributes;
19
19
use base:: { push_ctxt} ;
20
- use base:: trans_fn;
21
20
use base;
22
21
use common:: * ;
23
22
use declare;
@@ -27,17 +26,16 @@ use rustc::util::ppaux;
27
26
28
27
use rustc:: hir;
29
28
30
- use syntax:: attr;
31
29
use syntax:: errors;
32
30
33
31
use std:: fmt;
32
+ use trans_item:: TransItem ;
34
33
35
34
pub fn monomorphic_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
36
35
fn_id : DefId ,
37
36
psubsts : & ' tcx subst:: Substs < ' tcx > )
38
37
-> ( ValueRef , Ty < ' tcx > ) {
39
38
debug ! ( "monomorphic_fn(fn_id={:?}, real_substs={:?})" , fn_id, psubsts) ;
40
-
41
39
assert ! ( !psubsts. types. needs_infer( ) && !psubsts. types. has_param_types( ) ) ;
42
40
43
41
let _icx = push_ctxt ( "monomorphic_fn" ) ;
@@ -55,7 +53,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
55
53
debug ! ( "leaving monomorphic fn {:?}" , instance) ;
56
54
return ( val, mono_ty) ;
57
55
}
58
- None => ( )
56
+ None => {
57
+ assert ! ( !ccx. codegen_unit( ) . items. contains_key( & TransItem :: Fn ( instance) ) ) ;
58
+ }
59
59
}
60
60
61
61
debug ! ( "monomorphic_fn({:?})" , instance) ;
@@ -99,6 +99,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
99
99
100
100
ccx. instances ( ) . borrow_mut ( ) . insert ( instance, lldecl) ;
101
101
102
+
102
103
// we can only monomorphize things in this crate (or inlined into it)
103
104
let fn_node_id = ccx. tcx ( ) . map . as_local_node_id ( fn_id) . unwrap ( ) ;
104
105
let map_node = errors:: expect (
@@ -113,34 +114,18 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
113
114
match map_node {
114
115
hir_map:: NodeItem ( & hir:: Item {
115
116
ref attrs,
116
- node : hir:: ItemFn ( ref decl , _ , _ , _ , _ , ref body ) , ..
117
+ node : hir:: ItemFn ( .. ) , ..
117
118
} ) |
118
119
hir_map:: NodeImplItem ( & hir:: ImplItem {
119
120
ref attrs, node : hir:: ImplItemKind :: Method (
120
- hir:: MethodSig { ref decl , .. } , ref body ) , ..
121
+ hir:: MethodSig { .. } , _ ) , ..
121
122
} ) |
122
123
hir_map:: NodeTraitItem ( & hir:: TraitItem {
123
124
ref attrs, node : hir:: MethodTraitItem (
124
- hir:: MethodSig { ref decl , .. } , Some ( ref body ) ) , ..
125
+ hir:: MethodSig { .. } , Some ( _ ) ) , ..
125
126
} ) => {
126
127
attributes:: from_fn_attrs ( ccx, attrs, lldecl) ;
127
-
128
- let is_first = !ccx. available_monomorphizations ( ) . borrow ( )
129
- . contains ( & symbol) ;
130
- if is_first {
131
- ccx. available_monomorphizations ( ) . borrow_mut ( ) . insert ( symbol. clone ( ) ) ;
132
- }
133
-
134
- let trans_everywhere = attr:: requests_inline ( attrs) ;
135
- if trans_everywhere || is_first {
136
- let origin = if is_first { base:: OriginalTranslation } else { base:: InlinedCopy } ;
137
- base:: update_linkage ( ccx, lldecl, None , origin) ;
138
- trans_fn ( ccx, decl, body, lldecl, psubsts, fn_node_id) ;
139
- } else {
140
- // We marked the value as using internal linkage earlier, but that is illegal for
141
- // declarations, so switch back to external linkage.
142
- llvm:: SetLinkage ( lldecl, llvm:: ExternalLinkage ) ;
143
- }
128
+ llvm:: SetLinkage ( lldecl, llvm:: ExternalLinkage ) ;
144
129
}
145
130
146
131
hir_map:: NodeVariant ( _) | hir_map:: NodeStructCtor ( _) => {
0 commit comments