File tree 2 files changed +7
-25
lines changed
2 files changed +7
-25
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ use crate::ir::function::Abi;
2
2
use proc_macro2:: Ident ;
3
3
4
4
/// Used to build the output tokens for dynamic bindings.
5
+ #[ derive( Default ) ]
5
6
pub struct DynamicItems {
6
7
/// Tracks the tokens that will appears inside the library struct -- e.g.:
7
8
/// ```ignore
@@ -74,18 +75,6 @@ pub struct DynamicItems {
74
75
init_fields : Vec < proc_macro2:: TokenStream > ,
75
76
}
76
77
77
- impl Default for DynamicItems {
78
- fn default ( ) -> Self {
79
- DynamicItems {
80
- struct_members : vec ! [ ] ,
81
- struct_implementation : vec ! [ ] ,
82
- runtime_checks : vec ! [ ] ,
83
- constructor_inits : vec ! [ ] ,
84
- init_fields : vec ! [ ] ,
85
- }
86
- }
87
- }
88
-
89
78
impl DynamicItems {
90
79
pub fn new ( ) -> Self {
91
80
Self :: default ( )
@@ -141,7 +130,7 @@ impl DynamicItems {
141
130
}
142
131
}
143
132
144
- pub fn add_function (
133
+ pub fn push (
145
134
& mut self ,
146
135
ident : Ident ,
147
136
abi : Abi ,
Original file line number Diff line number Diff line change @@ -3805,7 +3805,7 @@ impl CodeGenerator for Function {
3805
3805
TypeKind :: Void => quote ! { ( ) } ,
3806
3806
_ => return_item. to_rust_ty_or_opaque ( ctx, & ( ) ) ,
3807
3807
} ;
3808
- result. dynamic_items ( ) . add_function (
3808
+ result. dynamic_items ( ) . push (
3809
3809
ident,
3810
3810
abi,
3811
3811
args,
@@ -4105,17 +4105,10 @@ pub(crate) fn codegen(
4105
4105
& ( ) ,
4106
4106
) ;
4107
4107
4108
- if context. options ( ) . dynamic_library_name . is_some ( ) {
4109
- let lib_ident = context. rust_ident (
4110
- context. options ( ) . dynamic_library_name . as_ref ( ) . unwrap ( ) ,
4111
- ) ;
4112
- let check_struct_ident = context. rust_ident (
4113
- [
4114
- "Check" ,
4115
- context. options ( ) . dynamic_library_name . as_ref ( ) . unwrap ( ) ,
4116
- ]
4117
- . join ( "" ) ,
4118
- ) ;
4108
+ if let Some ( ref lib_name) = context. options ( ) . dynamic_library_name {
4109
+ let lib_ident = context. rust_ident ( lib_name) ;
4110
+ let check_struct_ident =
4111
+ context. rust_ident ( format ! ( "Check{}" , lib_name) ) ;
4119
4112
let dynamic_items_tokens = result
4120
4113
. dynamic_items ( )
4121
4114
. get_tokens ( lib_ident, check_struct_ident) ;
You can’t perform that action at this time.
0 commit comments