66// option. This file may not be copied, modified, or distributed
77// except according to those terms.
88
9- use autocxx_parser:: IncludeCppConfig ;
109use indexmap:: set:: IndexSet as HashSet ;
1110use std:: borrow:: Cow ;
1211
@@ -24,15 +23,15 @@ use super::{
2423 function_wrapper_rs:: RustParamConversion ,
2524 maybe_unsafes_to_tokens,
2625 unqualify:: { unqualify_params, unqualify_ret_type} ,
27- ImplBlockDetails , ImplBlockKey , MaybeUnsafeStmt , RsCodegenResult , TraitImplBlockDetails , Use ,
26+ ImplBlockDetails , MaybeUnsafeStmt , RsCodegenResult , TraitImplBlockDetails , Use ,
2827} ;
2928use crate :: {
3029 conversion:: {
3130 analysis:: fun:: {
3231 function_wrapper:: TypeConversionPolicy , ArgumentAnalysis , FnAnalysis , FnKind ,
3332 MethodKind , RustRenameStrategy , TraitMethodDetails ,
3433 } ,
35- api:: { Pointerness , UnsafetyNeeded } ,
34+ api:: UnsafetyNeeded ,
3635 } ,
3736 minisyn:: minisynize_vec,
3837 types:: { Namespace , QualifiedName } ,
@@ -91,7 +90,6 @@ pub(super) fn gen_function(
9190 analysis : FnAnalysis ,
9291 cpp_call_name : String ,
9392 non_pod_types : & HashSet < QualifiedName > ,
94- config : & IncludeCppConfig ,
9593) -> RsCodegenResult {
9694 if analysis. ignore_reason . is_err ( ) || !analysis. externally_callable {
9795 return RsCodegenResult :: default ( ) ;
@@ -125,14 +123,14 @@ pub(super) fn gen_function(
125123 non_pod_types,
126124 ret_type : & ret_type,
127125 ret_conversion : & ret_conversion,
128- reference_wrappers : config. unsafe_policy . requires_cpprefs ( ) ,
129126 } ;
130127 // In rare occasions, we might need to give an explicit lifetime.
131128 let ( lifetime_tokens, params, ret_type) = add_explicit_lifetime_if_necessary (
132129 & param_details,
133130 params,
134131 Cow :: Borrowed ( & ret_type) ,
135132 non_pod_types,
133+ & ret_conversion,
136134 ) ;
137135
138136 if analysis. rust_wrapper_needed {
@@ -238,7 +236,6 @@ struct FnGenerator<'a> {
238236 always_unsafe_due_to_trait_definition : bool ,
239237 doc_attrs : & ' a Vec < Attribute > ,
240238 non_pod_types : & ' a HashSet < QualifiedName > ,
241- reference_wrappers : bool ,
242239}
243240
244241impl < ' a > FnGenerator < ' a > {
@@ -308,6 +305,7 @@ impl<'a> FnGenerator<'a> {
308305 wrapper_params,
309306 ret_type,
310307 self . non_pod_types ,
308+ self . ret_conversion ,
311309 ) ;
312310
313311 let cxxbridge_name = self . cxxbridge_name ;
@@ -394,39 +392,15 @@ impl<'a> FnGenerator<'a> {
394392 let rust_name = make_ident ( self . rust_name ) ;
395393 let unsafety = self . unsafety . wrapper_token ( ) ;
396394 let doc_attrs = self . doc_attrs ;
397- let receiver_pointerness = self
398- . param_details
399- . iter ( )
400- . next ( )
401- . map ( |pd| pd. conversion . is_a_pointer ( ) )
402- . unwrap_or ( Pointerness :: Not ) ;
403395 let ty = impl_block_type_name. get_final_ident ( ) ;
404- let ty = match receiver_pointerness {
405- Pointerness :: MutPtr if self . reference_wrappers => ImplBlockKey {
406- ty : parse_quote ! {
407- #ty
408- } ,
409- lifetime : Some ( parse_quote ! { ' a } ) ,
410- } ,
411- Pointerness :: ConstPtr if self . reference_wrappers => ImplBlockKey {
412- ty : parse_quote ! {
413- #ty
414- } ,
415- lifetime : Some ( parse_quote ! { ' a } ) ,
416- } ,
417- _ => ImplBlockKey {
418- ty : parse_quote ! { # ty } ,
419- lifetime : None ,
420- } ,
421- } ;
422396 Box :: new ( ImplBlockDetails {
423397 item : ImplItem :: Fn ( parse_quote ! {
424398 #( #doc_attrs) *
425399 pub #unsafety fn #rust_name #lifetime_tokens ( #wrapper_params ) #ret_type {
426400 #call_body
427401 }
428402 } ) ,
429- ty,
403+ ty : parse_quote ! { # ty } ,
430404 } )
431405 }
432406
@@ -469,7 +443,7 @@ impl<'a> FnGenerator<'a> {
469443 } ;
470444 Box :: new ( ImplBlockDetails {
471445 item : ImplItem :: Fn ( parse_quote ! { #stuff } ) ,
472- ty : ImplBlockKey { ty , lifetime : None } ,
446+ ty,
473447 } )
474448 }
475449
0 commit comments