Skip to content

Commit

Permalink
Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kngwyu committed Jun 28, 2020
1 parent f89e9e0 commit 42f592b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pyo3-derive-backend/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum MethodTypeAttribute {
Setter,
}

#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, Debug)]
pub enum FnType {
Getter(SelfType),
Setter(SelfType),
Expand All @@ -50,10 +50,10 @@ pub enum FnType {
ClassAttribute,
}

#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, Debug)]
pub enum SelfType {
Receiver { mutable: bool },
TryFromPyCell(syn::Type),
TryFromPyCell(proc_macro2::Span),
}

impl SelfType {
Expand All @@ -73,8 +73,8 @@ impl SelfType {
let _slf = &mut _ref;
}
}
SelfType::TryFromPyCell(ty) => {
quote_spanned! { ty.span() =>
SelfType::TryFromPyCell(span) => {
quote_spanned! { *span =>
let _cell = _py.from_borrowed_ptr::<pyo3::PyCell<#cls>>(_slf);
let _slf = std::convert::TryFrom::try_from(_cell)?;
}
Expand All @@ -83,7 +83,7 @@ impl SelfType {
}
}

#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, Debug)]
pub struct FnSpec<'a> {
pub tp: FnType,
// Rust function name
Expand All @@ -109,9 +109,7 @@ pub fn parse_method_receiver(arg: &syn::FnArg) -> syn::Result<SelfType> {
syn::FnArg::Receiver(recv) => Ok(SelfType::Receiver {
mutable: recv.mutability.is_some(),
}),
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => {
Ok(SelfType::TryFromPyCell(ty.as_ref().clone()))
}
syn::FnArg::Typed(syn::PatType { ref ty, .. }) => Ok(SelfType::TryFromPyCell(ty.span())),
}
}

Expand Down

0 comments on commit 42f592b

Please sign in to comment.