@@ -365,9 +365,7 @@ pub fn impl_py_method_def(
365365 } ;
366366 let methoddef = spec. get_methoddef ( quote ! { #cls:: #wrapper_ident } , doc, ctx) ;
367367 let method_def = quote ! {
368- #pyo3_path:: impl_:: pyclass:: MaybeRuntimePyMethodDef :: Static (
369- #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: #methoddef_type( #methoddef #add_flags)
370- )
368+ #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: #methoddef_type( #methoddef #add_flags)
371369 } ;
372370 Ok ( MethodAndMethodDef {
373371 associated_method,
@@ -600,14 +598,12 @@ pub(crate) fn impl_py_class_attribute(
600598 } ;
601599
602600 let method_def = quote ! {
603- #pyo3_path:: impl_:: pyclass:: MaybeRuntimePyMethodDef :: Static (
604- #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: ClassAttribute ( {
605- #pyo3_path:: impl_:: pymethods:: PyClassAttributeDef :: new(
606- #python_name,
607- #cls:: #wrapper_ident
608- )
609- } )
610- )
601+ #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: ClassAttribute ( {
602+ #pyo3_path:: impl_:: pymethods:: PyClassAttributeDef :: new(
603+ #python_name,
604+ #cls:: #wrapper_ident
605+ )
606+ } )
611607 } ;
612608
613609 Ok ( MethodAndMethodDef {
@@ -788,13 +784,11 @@ pub fn impl_py_setter_def(
788784
789785 let method_def = quote ! {
790786 #cfg_attrs
791- #pyo3_path:: impl_:: pyclass:: MaybeRuntimePyMethodDef :: Static (
792- #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: Setter (
793- #pyo3_path:: impl_:: pymethods:: PySetterDef :: new(
794- #python_name,
795- #cls:: #wrapper_ident,
796- #doc
797- )
787+ #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: Setter (
788+ #pyo3_path:: impl_:: pymethods:: PySetterDef :: new(
789+ #python_name,
790+ #cls:: #wrapper_ident,
791+ #doc
798792 )
799793 )
800794 } ;
@@ -862,33 +856,21 @@ pub fn impl_py_getter_def(
862856 syn:: Index :: from ( field_index) . to_token_stream ( )
863857 } ;
864858
865- // TODO: on MSRV 1.77+, we can use `::std::mem::offset_of!` here, and it should
866- // make it possible for the `MaybeRuntimePyMethodDef` to be a `Static` variant.
867859 let generator = quote_spanned ! { ty. span( ) =>
868- #pyo3_path:: impl_:: pyclass:: MaybeRuntimePyMethodDef :: Runtime (
869- || GENERATOR . generate( #python_name, #doc)
870- )
860+ GENERATOR . generate( #python_name, #doc)
871861 } ;
872- // This is separate so that the unsafe below does not inherit the span and thus does not
862+ // This is separate from `generator` so that the unsafe below does not inherit the span and thus does not
873863 // trigger the `unsafe_code` lint
874864 let method_def = quote ! {
875865 #cfg_attrs
876866 {
877867 #[ allow( unused_imports) ] // might not be used if all probes are positive
878868 use #pyo3_path:: impl_:: pyclass:: Probe as _;
879869
880- struct Offset ;
881- unsafe impl #pyo3_path:: impl_:: pyclass:: OffsetCalculator <#cls, #ty> for Offset {
882- fn offset( ) -> usize {
883- #pyo3_path:: impl_:: pyclass:: class_offset:: <#cls>( ) +
884- #pyo3_path:: impl_:: pyclass:: offset_of!( #cls, #field)
885- }
886- }
887-
888870 const GENERATOR : #pyo3_path:: impl_:: pyclass:: PyClassGetterGenerator :: <
889871 #cls,
890872 #ty,
891- Offset ,
873+ { :: std :: mem :: offset_of! ( #cls , #field ) } ,
892874 { #pyo3_path:: impl_:: pyclass:: IsPyT :: <#ty>:: VALUE } ,
893875 { #pyo3_path:: impl_:: pyclass:: IsIntoPyObjectRef :: <#ty>:: VALUE } ,
894876 { #pyo3_path:: impl_:: pyclass:: IsIntoPyObject :: <#ty>:: VALUE } ,
@@ -930,13 +912,11 @@ pub fn impl_py_getter_def(
930912
931913 let method_def = quote ! {
932914 #cfg_attrs
933- #pyo3_path:: impl_:: pyclass:: MaybeRuntimePyMethodDef :: Static (
934- #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: Getter (
935- #pyo3_path:: impl_:: pymethods:: PyGetterDef :: new(
936- #python_name,
937- #cls:: #wrapper_ident,
938- #doc
939- )
915+ #pyo3_path:: impl_:: pymethods:: PyMethodDefType :: Getter (
916+ #pyo3_path:: impl_:: pymethods:: PyGetterDef :: new(
917+ #python_name,
918+ #cls:: #wrapper_ident,
919+ #doc
940920 )
941921 )
942922 } ;
0 commit comments