File tree 2 files changed +35
-9
lines changed 2 files changed +35
-9
lines changed Original file line number Diff line number Diff line change @@ -2156,13 +2156,26 @@ impl MethodCodegen for Method {
2156
2156
// variable called `__bindgen_tmp` we're going to create.
2157
2157
if self . is_constructor ( ) {
2158
2158
let prefix = ctx. trait_prefix ( ) ;
2159
- let tmp_variable_decl = quote ! {
2160
- let mut __bindgen_tmp = :: #prefix:: mem:: uninitialized( )
2159
+ let tmp_variable_decl = if ctx
2160
+ . options ( )
2161
+ . rust_features ( )
2162
+ . maybe_uninit
2163
+ {
2164
+ exprs[ 0 ] = quote ! {
2165
+ __bindgen_tmp. as_mut_ptr( )
2166
+ } ;
2167
+ quote ! {
2168
+ let mut __bindgen_tmp = :: #prefix:: mem:: MaybeUninit :: uninit( )
2169
+ }
2170
+ } else {
2171
+ exprs[ 0 ] = quote ! {
2172
+ & mut __bindgen_tmp
2173
+ } ;
2174
+ quote ! {
2175
+ let mut __bindgen_tmp = :: #prefix:: mem:: uninitialized( )
2176
+ }
2161
2177
} ;
2162
2178
stmts. push ( tmp_variable_decl) ;
2163
- exprs[ 0 ] = quote ! {
2164
- & mut __bindgen_tmp
2165
- } ;
2166
2179
} else if !self . is_static ( ) {
2167
2180
assert ! ( !exprs. is_empty( ) ) ;
2168
2181
exprs[ 0 ] = quote ! {
@@ -2177,9 +2190,15 @@ impl MethodCodegen for Method {
2177
2190
stmts. push ( call) ;
2178
2191
2179
2192
if self . is_constructor ( ) {
2180
- stmts. push ( quote ! {
2181
- __bindgen_tmp
2182
- } ) ;
2193
+ stmts. push ( if ctx. options ( ) . rust_features ( ) . maybe_uninit {
2194
+ quote ! {
2195
+ __bindgen_tmp. assume_init( )
2196
+ }
2197
+ } else {
2198
+ quote ! {
2199
+ __bindgen_tmp
2200
+ }
2201
+ } )
2183
2202
}
2184
2203
2185
2204
let block = quote ! {
Original file line number Diff line number Diff line change @@ -118,6 +118,9 @@ macro_rules! rust_target_base {
118
118
/// Rust stable 1.33
119
119
/// * repr(packed(N)) ([PR](https://github.com/rust-lang/rust/pull/57049))
120
120
=> Stable_1_33 => 1.33 ;
121
+ /// Rust stable 1.36
122
+ /// * `MaybeUninit` instead of `mem::uninitialized()` ([PR](https://github.com/rust-lang/rust/pull/60445))
123
+ => Stable_1_36 => 1.36 ;
121
124
/// Nightly rust
122
125
/// * `thiscall` calling convention ([Tracking issue](https://github.com/rust-lang/rust/issues/42202))
123
126
/// * `non_exhaustive` enums/structs ([Tracking issue](https://github.com/rust-lang/rust/issues/44109))
@@ -130,7 +133,7 @@ rust_target_base!(rust_target_def);
130
133
rust_target_base ! ( rust_target_values_def) ;
131
134
132
135
/// Latest stable release of Rust
133
- pub const LATEST_STABLE_RUST : RustTarget = RustTarget :: Stable_1_33 ;
136
+ pub const LATEST_STABLE_RUST : RustTarget = RustTarget :: Stable_1_36 ;
134
137
135
138
/// Create RustFeatures struct definition, new(), and a getter for each field
136
139
macro_rules! rust_feature_def {
@@ -212,6 +215,9 @@ rust_feature_def!(
212
215
Stable_1_33 {
213
216
=> repr_packed_n;
214
217
}
218
+ Stable_1_36 {
219
+ => maybe_uninit;
220
+ }
215
221
Nightly {
216
222
=> thiscall_abi;
217
223
=> non_exhaustive;
@@ -256,6 +262,7 @@ mod test {
256
262
f_nightly. untagged_union &&
257
263
f_nightly. associated_const &&
258
264
f_nightly. builtin_clone_impls &&
265
+ f_nightly. maybe_uninit &&
259
266
f_nightly. repr_align &&
260
267
f_nightly. thiscall_abi
261
268
) ;
You can’t perform that action at this time.
0 commit comments