From 48d760bc1f6b3020ba14bd3ec0fe35191d28bcd4 Mon Sep 17 00:00:00 2001 From: qwerty2501 <939468+qwerty2501@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:53:59 +0900 Subject: [PATCH] =?UTF-8?q?[Rust]unsafe=E3=81=AA=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=92=E5=8E=9F=E5=89=87=E7=A6=81=E6=AD=A2=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F=20(#175)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unsafeなコードを原則禁止にした unsafe_codeをdenyにすることにより、うっかりunsafeコードを書くのを防ぐことが目的 例外としてc関数向けの実装である c_export moduleと、static領域に配置する必要があるStatus structについてはunsafeを使うことを許可している refs #128 --- crates/voicevox_core/src/lib.rs | 3 +++ crates/voicevox_core/src/status.rs | 2 ++ 2 files changed, 5 insertions(+) diff --git a/crates/voicevox_core/src/lib.rs b/crates/voicevox_core/src/lib.rs index fff9d4926..beb654cf9 100644 --- a/crates/voicevox_core/src/lib.rs +++ b/crates/voicevox_core/src/lib.rs @@ -1,3 +1,6 @@ +#![deny(unsafe_code)] + +#[allow(unsafe_code)] mod c_export; mod engine; mod error; diff --git a/crates/voicevox_core/src/status.rs b/crates/voicevox_core/src/status.rs index 4e97b9872..8c2bfba5d 100644 --- a/crates/voicevox_core/src/status.rs +++ b/crates/voicevox_core/src/status.rs @@ -93,7 +93,9 @@ impl SupportedDevices { } } +#[allow(unsafe_code)] unsafe impl Send for Status {} +#[allow(unsafe_code)] unsafe impl Sync for Status {} impl Status {