Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Mar 26, 2024
1 parent 937fbb1 commit 1f0f7fd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 23 deletions.
10 changes: 0 additions & 10 deletions pyo3-macros-backend/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,13 @@ 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]>,
pub unsafety: Option<syn::Token![unsafe]>,
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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -361,7 +352,6 @@ impl<'a> FnSpec<'a> {
convention,
python_name,
signature,
output: ty,
text_signature,
asyncness: sig.asyncness,
unsafety: sig.unsafety,
Expand Down
12 changes: 2 additions & 10 deletions pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand All @@ -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> {
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions pyo3-macros-backend/src/pyfunction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1f0f7fd

Please sign in to comment.