@@ -93,46 +93,9 @@ ExportContext::emit_function (const HIR::Function &fn)
93
93
// FIXME assert that this is actually an AST::Function
94
94
AST::Function &function = static_cast <AST::Function &> (vis_item);
95
95
96
- // we can emit an extern block with abi of "rust"
97
- Identifier item_name = function.get_function_name ();
98
-
99
- // always empty for extern linkage
100
- AST::WhereClause where_clause = AST::WhereClause::create_empty ();
101
- std::vector<std::unique_ptr<AST::GenericParam>> generic_params;
102
-
103
- AST::Visibility vis = function.get_visibility ();
104
- std::unique_ptr<AST::Type> return_type
105
- = std::unique_ptr<AST::Type> (nullptr );
106
- if (function.has_return_type ())
107
- {
108
- return_type = function.get_return_type ()->clone_type ();
109
- }
110
-
111
- std::vector<AST::NamedFunctionParam> function_params;
112
- for (auto &p : function.get_function_params ())
113
- {
114
- if (p->is_variadic () || p->is_self ())
115
- rust_unreachable ();
116
- auto param = static_cast <AST::FunctionParam *> (p.get ());
117
- std::string name = param->get_pattern ()->as_string ();
118
- std::unique_ptr<AST::Type> param_type
119
- = param->get_type ()->clone_type ();
120
-
121
- AST::NamedFunctionParam np (name, std::move (param_type), {},
122
- param->get_locus ());
123
- function_params.push_back (std::move (np));
124
- }
125
-
126
- AST::ExternalItem *external_item
127
- = new AST::ExternalFunctionItem (item_name, {} /* generic_params */ ,
128
- std::move (return_type), where_clause,
129
- std::move (function_params), vis,
130
- function.get_outer_attrs (),
131
- function.get_locus ());
132
-
133
96
std::vector<std::unique_ptr<AST::ExternalItem>> external_items;
134
- external_items.push_back (
135
- std::unique_ptr <AST::ExternalItem> (external_item ));
97
+ external_items.push_back (std::unique_ptr<AST::ExternalItem> (
98
+ static_cast <AST::ExternalItem * > (&function) ));
136
99
137
100
AST::ExternBlock extern_block (get_string_from_abi (Rust::ABI::RUST),
138
101
std::move (external_items),
0 commit comments