Skip to content

Commit ea75c72

Browse files
committed
chore: Rustを1.82.0に上げ、その新機能を利用する
Rustを1.82.0に上げてClippyの対応を行うとともに、次の新機能を利用する。 - `unsafe_attributes` (rust-lang/rust#128771) - `raw_ref_op` (rust-lang/rust#127679)
1 parent 683da55 commit ea75c72

File tree

15 files changed

+229
-67
lines changed

15 files changed

+229
-67
lines changed

crates/voicevox_core/src/devices.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,15 @@ mod tests {
230230
reason = "比較対象としてここは網羅されてなければなりません"
231231
)]
232232
let SupportedDevices { cpu: _, cuda, dml } = &SUPPORTED_DEVICES;
233-
[cuda as *const _, dml as *const _]
233+
#[expect(
234+
clippy::borrow_deref_ref,
235+
reason = "多分raw記法自体にまだ対応していない"
236+
)]
237+
[&raw const *cuda, &raw const *dml]
234238
},
235239
*GpuSpec::defaults()
236240
.into_iter()
237-
.map(|gpu| &SUPPORTED_DEVICES[gpu] as *const _)
241+
.map(|gpu| &raw const SUPPORTED_DEVICES[gpu])
238242
.collect::<Vec<_>>(),
239243
);
240244
}

crates/voicevox_core/src/infer/runtimes/onnxruntime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub(crate) mod blocking {
282282
/// assert_eq!(ptr_addr(ort1), ptr_addr(ort2));
283283
///
284284
/// fn ptr_addr(obj: &impl Sized) -> usize {
285-
/// obj as *const _ as _
285+
/// &raw const *obj as _
286286
/// }
287287
/// # Ok(())
288288
/// # }

crates/voicevox_core_c_api/src/compatible_engine.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ fn set_message(message: &str) {
112112
.replace_range(.., &format!("{message}\0"));
113113
}
114114

115-
#[no_mangle]
115+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
116+
#[unsafe(no_mangle)]
116117
pub extern "C" fn initialize(use_gpu: bool, cpu_num_threads: c_int, load_all_models: bool) -> bool {
117118
init_logger_once();
118119
let result = (|| {
@@ -150,7 +151,8 @@ pub extern "C" fn initialize(use_gpu: bool, cpu_num_threads: c_int, load_all_mod
150151
}
151152
}
152153

153-
#[no_mangle]
154+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
155+
#[unsafe(no_mangle)]
154156
pub extern "C" fn load_model(style_id: i64) -> bool {
155157
init_logger_once();
156158
let style_id = StyleId::new(style_id as u32);
@@ -171,33 +173,38 @@ pub extern "C" fn load_model(style_id: i64) -> bool {
171173
}
172174
}
173175

174-
#[no_mangle]
176+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
177+
#[unsafe(no_mangle)]
175178
pub extern "C" fn is_model_loaded(speaker_id: i64) -> bool {
176179
init_logger_once();
177180
ensure_initialized!(&*lock_synthesizer())
178181
.is_loaded_model_by_style_id(StyleId::new(speaker_id as u32))
179182
}
180183

181-
#[no_mangle]
184+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
185+
#[unsafe(no_mangle)]
182186
pub extern "C" fn finalize() {
183187
init_logger_once();
184188
*lock_synthesizer() = None;
185189
}
186190

187-
#[no_mangle]
191+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
192+
#[unsafe(no_mangle)]
188193
pub extern "C" fn metas() -> *const c_char {
189194
init_logger_once();
190195
let model_set = voice_model_set();
191196
model_set.all_metas_json.as_ptr()
192197
}
193198

194-
#[no_mangle]
199+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
200+
#[unsafe(no_mangle)]
195201
pub extern "C" fn last_error_message() -> *const c_char {
196202
init_logger_once();
197203
ERROR_MESSAGE.lock().unwrap().as_ptr() as *const c_char
198204
}
199205

200-
#[no_mangle]
206+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
207+
#[unsafe(no_mangle)]
201208
pub extern "C" fn supported_devices() -> *const c_char {
202209
init_logger_once();
203210
return SUPPORTED_DEVICES.as_ptr();
@@ -214,7 +221,8 @@ pub extern "C" fn supported_devices() -> *const c_char {
214221
});
215222
}
216223

217-
#[no_mangle]
224+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
225+
#[unsafe(no_mangle)]
218226
pub extern "C" fn yukarin_s_forward(
219227
length: i64,
220228
phoneme_list: *mut i64,
@@ -240,7 +248,8 @@ pub extern "C" fn yukarin_s_forward(
240248
}
241249
}
242250

243-
#[no_mangle]
251+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
252+
#[unsafe(no_mangle)]
244253
pub extern "C" fn yukarin_sa_forward(
245254
length: i64,
246255
vowel_phoneme_list: *mut i64,
@@ -277,7 +286,8 @@ pub extern "C" fn yukarin_sa_forward(
277286
}
278287
}
279288

280-
#[no_mangle]
289+
// SAFETY: voicevox_core_c_apiを構成するライブラリの中に、これと同名のシンボルは存在しない
290+
#[unsafe(no_mangle)]
281291
pub extern "C" fn decode_forward(
282292
length: i64,
283293
phoneme_size: i64,

0 commit comments

Comments
 (0)