Remove dead code in macros backend (#4011)

This commit is contained in:
Alex Gaynor 2024-03-29 17:28:08 -04:00 committed by GitHub
parent c6f25e42a2
commit de03ca270a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 2 additions and 23 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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,