Skip to content

Commit 3f6ab7c

Browse files
committed
Revert "Add missing #[allow(unsafe_code)] attributes (#4396)"
This reverts commit 0e03b39.
1 parent 0079003 commit 3f6ab7c

File tree

7 files changed

+1
-12
lines changed

7 files changed

+1
-12
lines changed

newsfragments/4396.fixed.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

pyo3-macros-backend/src/pyclass.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,6 @@ fn impl_pytypeinfo(cls: &syn::Ident, attr: &PyClassArgs, ctx: &Ctx) -> TokenStre
18091809
};
18101810

18111811
quote! {
1812-
#[allow(unsafe_code)]
18131812
unsafe impl #pyo3_path::type_object::PyTypeInfo for #cls {
18141813
const NAME: &'static str = #cls_name;
18151814
const MODULE: ::std::option::Option<&'static str> = #module;

pyo3-macros-backend/src/pymethod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,15 +773,13 @@ pub fn impl_py_getter_def(
773773
use #pyo3_path::impl_::pyclass::Probe;
774774

775775
struct Offset;
776-
#[allow(unsafe_code)]
777776
unsafe impl #pyo3_path::impl_::pyclass::OffsetCalculator<#cls, #ty> for Offset {
778777
fn offset() -> usize {
779778
#pyo3_path::impl_::pyclass::class_offset::<#cls>() +
780779
#pyo3_path::impl_::pyclass::offset_of!(#cls, #field)
781780
}
782781
}
783782

784-
#[allow(unsafe_code)]
785783
const GENERATOR: #pyo3_path::impl_::pyclass::PyClassGetterGenerator::<
786784
#cls,
787785
#ty,

src/impl_/pyclass.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ slot_fragment_trait! {
351351
#[macro_export]
352352
macro_rules! generate_pyclass_getattro_slot {
353353
($cls:ty) => {{
354-
#[allow(unsafe_code)]
355354
unsafe extern "C" fn __wrap(
356355
_slf: *mut $crate::ffi::PyObject,
357356
attr: *mut $crate::ffi::PyObject,
@@ -435,7 +434,6 @@ macro_rules! define_pyclass_setattr_slot {
435434
#[macro_export]
436435
macro_rules! $generate_macro {
437436
($cls:ty) => {{
438-
#[allow(unsafe_code)]
439437
unsafe extern "C" fn __wrap(
440438
_slf: *mut $crate::ffi::PyObject,
441439
attr: *mut $crate::ffi::PyObject,
@@ -552,7 +550,6 @@ macro_rules! define_pyclass_binary_operator_slot {
552550
#[macro_export]
553551
macro_rules! $generate_macro {
554552
($cls:ty) => {{
555-
#[allow(unsafe_code)]
556553
unsafe extern "C" fn __wrap(
557554
_slf: *mut $crate::ffi::PyObject,
558555
_other: *mut $crate::ffi::PyObject,
@@ -745,7 +742,6 @@ slot_fragment_trait! {
745742
#[macro_export]
746743
macro_rules! generate_pyclass_pow_slot {
747744
($cls:ty) => {{
748-
#[allow(unsafe_code)]
749745
unsafe extern "C" fn __wrap(
750746
_slf: *mut $crate::ffi::PyObject,
751747
_other: *mut $crate::ffi::PyObject,
@@ -870,7 +866,7 @@ macro_rules! generate_pyclass_richcompare_slot {
870866
($cls:ty) => {{
871867
#[allow(unknown_lints, non_local_definitions)]
872868
impl $cls {
873-
#[allow(non_snake_case, unsafe_code)]
869+
#[allow(non_snake_case)]
874870
unsafe extern "C" fn __pymethod___richcmp____(
875871
slf: *mut $crate::ffi::PyObject,
876872
other: *mut $crate::ffi::PyObject,

src/macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ macro_rules! wrap_pymodule {
184184
#[macro_export]
185185
macro_rules! append_to_inittab {
186186
($module:ident) => {
187-
#[allow(unsafe_code)]
188187
unsafe {
189188
if $crate::ffi::Py_IsInitialized() != 0 {
190189
::std::panic!(

src/tests/hygiene/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![no_implicit_prelude]
22
#![allow(dead_code, unused_variables, clippy::unnecessary_wraps)]
3-
#![deny(unsafe_code)]
43

54
// The modules in this test are used to check PyO3 macro expansion is hygienic. By locating the test
65
// inside the crate the global `::pyo3` namespace is not available, so in combination with

src/types/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ macro_rules! pyobject_native_static_type_object(
153153
#[macro_export]
154154
macro_rules! pyobject_native_type_info(
155155
($name:ty, $typeobject:expr, $module:expr $(, #checkfunction=$checkfunction:path)? $(;$generics:ident)*) => {
156-
#[allow(unsafe_code)]
157156
unsafe impl<$($generics,)*> $crate::type_object::PyTypeInfo for $name {
158157
const NAME: &'static str = stringify!($name);
159158
const MODULE: ::std::option::Option<&'static str> = $module;

0 commit comments

Comments
 (0)