@@ -17,7 +17,6 @@ use rustc::ty::subst::{Subst, Substs};
1717use rustc:: ty:: { self , Ty , TypeFoldable , TyCtxt } ;
1818use attributes;
1919use base:: { push_ctxt} ;
20- use base:: trans_fn;
2120use base;
2221use common:: * ;
2322use declare;
@@ -27,17 +26,16 @@ use rustc::util::ppaux;
2726
2827use rustc:: hir;
2928
30- use syntax:: attr;
3129use syntax:: errors;
3230
3331use std:: fmt;
32+ use trans_item:: TransItem ;
3433
3534pub fn monomorphic_fn < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
3635 fn_id : DefId ,
3736 psubsts : & ' tcx subst:: Substs < ' tcx > )
3837 -> ( ValueRef , Ty < ' tcx > ) {
3938 debug ! ( "monomorphic_fn(fn_id={:?}, real_substs={:?})" , fn_id, psubsts) ;
40-
4139 assert ! ( !psubsts. types. needs_infer( ) && !psubsts. types. has_param_types( ) ) ;
4240
4341 let _icx = push_ctxt ( "monomorphic_fn" ) ;
@@ -55,7 +53,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
5553 debug ! ( "leaving monomorphic fn {:?}" , instance) ;
5654 return ( val, mono_ty) ;
5755 }
58- None => ( )
56+ None => {
57+ assert ! ( !ccx. codegen_unit( ) . items. contains_key( & TransItem :: Fn ( instance) ) ) ;
58+ }
5959 }
6060
6161 debug ! ( "monomorphic_fn({:?})" , instance) ;
@@ -99,6 +99,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
9999
100100 ccx. instances ( ) . borrow_mut ( ) . insert ( instance, lldecl) ;
101101
102+
102103 // we can only monomorphize things in this crate (or inlined into it)
103104 let fn_node_id = ccx. tcx ( ) . map . as_local_node_id ( fn_id) . unwrap ( ) ;
104105 let map_node = errors:: expect (
@@ -113,34 +114,18 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
113114 match map_node {
114115 hir_map:: NodeItem ( & hir:: Item {
115116 ref attrs,
116- node : hir:: ItemFn ( ref decl , _ , _ , _ , _ , ref body ) , ..
117+ node : hir:: ItemFn ( .. ) , ..
117118 } ) |
118119 hir_map:: NodeImplItem ( & hir:: ImplItem {
119120 ref attrs, node : hir:: ImplItemKind :: Method (
120- hir:: MethodSig { ref decl , .. } , ref body ) , ..
121+ hir:: MethodSig { .. } , _ ) , ..
121122 } ) |
122123 hir_map:: NodeTraitItem ( & hir:: TraitItem {
123124 ref attrs, node : hir:: MethodTraitItem (
124- hir:: MethodSig { ref decl , .. } , Some ( ref body ) ) , ..
125+ hir:: MethodSig { .. } , Some ( _ ) ) , ..
125126 } ) => {
126127 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 ) ;
144129 }
145130
146131 hir_map:: NodeVariant ( _) | hir_map:: NodeStructCtor ( _) => {
0 commit comments