File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -659,12 +659,24 @@ fn expand_cxx_function_shim(efn: &ExternFn, types: &Types) -> TokenStream {
659659 } ,
660660 inner if types. is_considered_improper_ctype ( inner) => {
661661 let mutability = ty. mutability ;
662- let deref_mut = quote_spanned ! ( span=> & #mutability * #call. cast( ) ) ;
663- match ty. pinned {
664- false => deref_mut,
662+ let cast_call = quote_spanned ! ( span=> let __ptr = #call. cast( ) ) ;
663+ let unpinned = quote_spanned ! ( span=> & #mutability * __ptr) ;
664+ let maybe_pinned = match ty. pinned {
665+ false => unpinned,
665666 true => {
666- quote_spanned ! ( span=> :: std:: pin:: Pin :: new_unchecked( #deref_mut ) )
667+ quote_spanned ! ( span=> :: std:: pin:: Pin :: new_unchecked( #unpinned ) )
667668 }
669+ } ;
670+ match ty. option {
671+ false => quote_spanned ! ( span=> #cast_call; #maybe_pinned) ,
672+ true => quote_spanned ! { span=>
673+ #cast_call;
674+ if __ptr. is_null( ) {
675+ :: std:: option:: Option :: None
676+ } else {
677+ :: std:: option:: Option :: Some ( #maybe_pinned)
678+ }
679+ } ,
668680 }
669681 }
670682 _ => call,
You can’t perform that action at this time.
0 commit comments