Skip to content

Commit

Permalink
Update rust toolchain 1.67.0 (VOICEVOX#396)
Browse files Browse the repository at this point in the history
Co-authored-by: PickledChair <[email protected]>
Co-authored-by: Ryo Yamashita <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2023
1 parent 3e7a5cb commit bec9e3e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 28 deletions.
10 changes: 7 additions & 3 deletions crates/voicevox_core/src/engine/full_context_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum FullContextLabelError {
TooLongMora { mora_phonemes: Vec<Phoneme> },

#[error("invalid mora:{mora:?}")]
InvalidMora { mora: Mora },
InvalidMora { mora: Box<Mora> },

#[error(transparent)]
OpenJtalk(#[from] open_jtalk::OpenJtalkError),
Expand Down Expand Up @@ -151,9 +151,13 @@ impl AccentPhrase {
.vowel()
.contexts()
.get("f2")
.ok_or_else(|| FullContextLabelError::InvalidMora { mora: mora.clone() })?
.ok_or_else(|| FullContextLabelError::InvalidMora {
mora: mora.clone().into(),
})?
.parse()
.map_err(|_| FullContextLabelError::InvalidMora { mora: mora.clone() })?;
.map_err(|_| FullContextLabelError::InvalidMora {
mora: mora.clone().into(),
})?;

let is_interrogative = moras
.last()
Expand Down
15 changes: 5 additions & 10 deletions crates/voicevox_core/src/engine/kana_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ fn text_to_accent_phrase(phrase: &str) -> KanaParseResult<AccentPhraseModel> {
if letter == ACCENT_SYMBOL {
if index == 0 {
return Err(KanaParseError(format!(
"accent cannot be set at beginning of accent phrase: {}",
phrase
"accent cannot be set at beginning of accent phrase: {phrase}"
)));
}
if accent_index.is_some() {
return Err(KanaParseError(format!(
"second accent cannot be set at an accent phrase: {}",
phrase
"second accent cannot be set at an accent phrase: {phrase}"
)));
}
accent_index = Some(moras.len());
Expand All @@ -104,8 +102,7 @@ fn text_to_accent_phrase(phrase: &str) -> KanaParseResult<AccentPhraseModel> {
stack.clear();
} else {
return Err(KanaParseError(format!(
"unknown text in accent phrase: {}",
phrase
"unknown text in accent phrase: {phrase}"
)));
}
if loop_count > LOOP_LIMIT {
Expand All @@ -114,8 +111,7 @@ fn text_to_accent_phrase(phrase: &str) -> KanaParseResult<AccentPhraseModel> {
}
if accent_index.is_none() {
return Err(KanaParseError(format!(
"accent not found in accent phrase: {}",
phrase
"accent not found in accent phrase: {phrase}"
)));
}
Ok(AccentPhraseModel::new(
Expand Down Expand Up @@ -145,8 +141,7 @@ pub fn parse_kana(text: &str) -> KanaParseResult<Vec<AccentPhraseModel>> {
!= phrase.len() - WIDE_INTERROGATION_MARK.len_utf8()
{
return Err(KanaParseError(format!(
"interrogative mark cannot be set at not end of accent phrase: {}",
phrase
"interrogative mark cannot be set at not end of accent phrase: {phrase}"
)));
}
phrase.pop(); // remove WIDE_INTERROGATION_MARK
Expand Down
10 changes: 5 additions & 5 deletions crates/voicevox_core/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,11 @@ mod tests {
fn supported_devices_works() {
let internal = VoicevoxCore::new_with_mutex();
let cstr_result = internal.lock().unwrap().get_supported_devices_json();
assert!(cstr_result.to_str().is_ok(), "{:?}", cstr_result);
assert!(cstr_result.to_str().is_ok(), "{cstr_result:?}");

let json_result: std::result::Result<SupportedDevices, _> =
serde_json::from_str(cstr_result.to_str().unwrap());
assert!(json_result.is_ok(), "{:?}", json_result);
assert!(json_result.is_ok(), "{json_result:?}");
}

#[rstest]
Expand Down Expand Up @@ -811,7 +811,7 @@ mod tests {
.unwrap()
.predict_duration(&phoneme_vector, 0);

assert!(result.is_ok(), "{:?}", result);
assert!(result.is_ok(), "{result:?}");
assert_eq!(result.unwrap().len(), phoneme_vector.len());
}

Expand Down Expand Up @@ -847,7 +847,7 @@ mod tests {
0,
);

assert!(result.is_ok(), "{:?}", result);
assert!(result.is_ok(), "{result:?}");
assert_eq!(result.unwrap().len(), vowel_phoneme_vector.len());
}

Expand Down Expand Up @@ -891,7 +891,7 @@ mod tests {
.unwrap()
.decode(F0_LENGTH, PHONEME_SIZE, &f0, &phoneme, 0);

assert!(result.is_ok(), "{:?}", result);
assert!(result.is_ok(), "{result:?}");
assert_eq!(result.unwrap().len(), F0_LENGTH * 256);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/voicevox_core/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ mod tests {
fn supported_devices_get_supported_devices_works() {
let result = SupportedDevices::get_supported_devices();
// 環境によって結果が変わるので、関数呼び出しが成功するかどうかの確認のみ行う
assert!(result.is_ok(), "{:?}", result);
assert!(result.is_ok(), "{result:?}");
}

#[rstest]
Expand Down
3 changes: 1 addition & 2 deletions crates/voicevox_core/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub async fn download_open_jtalk_dict_if_no_exists() -> PathBuf {

async fn download_open_jtalk_dict(open_jtalk_dic_dir: impl AsRef<Path>) {
let download_url = format!(
"https://github.com/r9y9/open_jtalk/releases/download/v1.11.1/{}.tar.gz",
DIC_DIR_NAME
"https://github.com/r9y9/open_jtalk/releases/download/v1.11.1/{DIC_DIR_NAME}.tar.gz"
);

let req = surf::get(download_url);
Expand Down
12 changes: 6 additions & 6 deletions crates/voicevox_core_c_api/src/compatible_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn set_message(message: &str) {
ERROR_MESSAGE
.lock()
.unwrap()
.replace_range(.., &format!("{}\0", message));
.replace_range(.., &format!("{message}\0"));
}

#[no_mangle]
Expand All @@ -25,7 +25,7 @@ pub extern "C" fn initialize(use_gpu: bool, cpu_num_threads: c_int, load_all_mod
..Default::default()
});
if let Some(err) = result.err() {
set_message(&format!("{}", err));
set_message(&format!("{err}"));
false
} else {
true
Expand All @@ -36,7 +36,7 @@ pub extern "C" fn initialize(use_gpu: bool, cpu_num_threads: c_int, load_all_mod
pub extern "C" fn load_model(speaker_id: i64) -> bool {
let result = lock_internal().load_model(speaker_id as u32);
if let Some(err) = result.err() {
set_message(&format!("{}", err));
set_message(&format!("{err}"));
false
} else {
true
Expand Down Expand Up @@ -86,7 +86,7 @@ pub extern "C" fn yukarin_s_forward(
true
}
Err(err) => {
set_message(&format!("{}", err));
set_message(&format!("{err}"));
false
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ pub extern "C" fn yukarin_sa_forward(
true
}
Err(err) => {
set_message(&format!("{}", err));
set_message(&format!("{err}"));
false
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ pub extern "C" fn decode_forward(
true
}
Err(err) => {
set_message(&format!("{}", err));
set_message(&format!("{err}"));
false
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.66.1
1.67.0

0 comments on commit bec9e3e

Please sign in to comment.