Remove dead code in macros backend (#4011)
This commit is contained in:
parent
c6f25e42a2
commit
de03ca270a
|
@ -269,7 +269,6 @@ pub struct FnSpec<'a> {
|
|||
// r# can be removed by syn::ext::IdentExt::unraw()
|
||||
pub python_name: syn::Ident,
|
||||
pub signature: FunctionSignature<'a>,
|
||||
pub output: syn::Type,
|
||||
pub convention: CallingConvention,
|
||||
pub text_signature: Option<TextSignatureAttribute>,
|
||||
pub asyncness: Option<syn::Token![async]>,
|
||||
|
@ -277,13 +276,6 @@ pub struct FnSpec<'a> {
|
|||
pub deprecations: Deprecations<'a>,
|
||||
}
|
||||
|
||||
pub fn get_return_info(output: &syn::ReturnType) -> syn::Type {
|
||||
match output {
|
||||
syn::ReturnType::Default => syn::Type::Infer(syn::parse_quote! {_}),
|
||||
syn::ReturnType::Type(_, ty) => *ty.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_method_receiver(arg: &syn::FnArg) -> Result<SelfType> {
|
||||
match arg {
|
||||
syn::FnArg::Receiver(
|
||||
|
@ -329,7 +321,6 @@ impl<'a> FnSpec<'a> {
|
|||
ensure_signatures_on_valid_method(&fn_type, signature.as_ref(), text_signature.as_ref())?;
|
||||
|
||||
let name = &sig.ident;
|
||||
let ty = get_return_info(&sig.output);
|
||||
let python_name = python_name.as_ref().unwrap_or(name).unraw();
|
||||
|
||||
let arguments: Vec<_> = sig
|
||||
|
@ -361,7 +352,6 @@ impl<'a> FnSpec<'a> {
|
|||
convention,
|
||||
python_name,
|
||||
signature,
|
||||
output: ty,
|
||||
text_signature,
|
||||
asyncness: sig.asyncness,
|
||||
unsafety: sig.unsafety,
|
||||
|
|
|
@ -975,13 +975,8 @@ fn impl_complex_enum_struct_variant_cls(
|
|||
let field_type = field.ty;
|
||||
let field_with_type = quote! { #field_name: #field_type };
|
||||
|
||||
let field_getter = complex_enum_variant_field_getter(
|
||||
&variant_cls_type,
|
||||
field_name,
|
||||
field_type,
|
||||
field.span,
|
||||
ctx,
|
||||
)?;
|
||||
let field_getter =
|
||||
complex_enum_variant_field_getter(&variant_cls_type, field_name, field.span, ctx)?;
|
||||
|
||||
let field_getter_impl = quote! {
|
||||
fn #field_name(slf: #pyo3_path::PyRef<Self>) -> #pyo3_path::PyResult<#field_type> {
|
||||
|
@ -1188,7 +1183,6 @@ fn complex_enum_struct_variant_new<'a>(
|
|||
name: &format_ident!("__pymethod_constructor__"),
|
||||
python_name: format_ident!("__new__"),
|
||||
signature,
|
||||
output: variant_cls_type.clone(),
|
||||
convention: crate::method::CallingConvention::TpNew,
|
||||
text_signature: None,
|
||||
asyncness: None,
|
||||
|
@ -1202,7 +1196,6 @@ fn complex_enum_struct_variant_new<'a>(
|
|||
fn complex_enum_variant_field_getter<'a>(
|
||||
variant_cls_type: &'a syn::Type,
|
||||
field_name: &'a syn::Ident,
|
||||
field_type: &'a syn::Type,
|
||||
field_span: Span,
|
||||
ctx: &Ctx,
|
||||
) -> Result<MethodAndMethodDef> {
|
||||
|
@ -1215,7 +1208,6 @@ fn complex_enum_variant_field_getter<'a>(
|
|||
name: field_name,
|
||||
python_name: field_name.clone(),
|
||||
signature,
|
||||
output: field_type.clone(),
|
||||
convention: crate::method::CallingConvention::Noargs,
|
||||
text_signature: None,
|
||||
asyncness: None,
|
||||
|
|
|
@ -240,15 +240,12 @@ pub fn impl_wrap_pyfunction(
|
|||
FunctionSignature::from_arguments(arguments)?
|
||||
};
|
||||
|
||||
let ty = method::get_return_info(&func.sig.output);
|
||||
|
||||
let spec = method::FnSpec {
|
||||
tp,
|
||||
name: &func.sig.ident,
|
||||
convention: CallingConvention::from_signature(&signature),
|
||||
python_name,
|
||||
signature,
|
||||
output: ty,
|
||||
text_signature,
|
||||
asyncness: func.sig.asyncness,
|
||||
unsafety: func.sig.unsafety,
|
||||
|
|
Loading…
Reference in New Issue