diff --git a/compiler/erg_common/build.rs b/compiler/erg_common/build.rs index c4f10cb8..96a481b1 100644 --- a/compiler/erg_common/build.rs +++ b/compiler/erg_common/build.rs @@ -8,7 +8,7 @@ fn main() -> std::io::Result<()> { .args(&["rev-parse", "--short", "HEAD"]) .output() .expect("failed to get the git hash"); - let git_hash_short = String::from_utf8(output.stdout).unwrap(); + let git_hash_short = String::from_utf8_lossy(&output.stdout); let now = datetime::now(); println!("cargo:rustc-env=GIT_HASH_SHORT={git_hash_short}"); println!("cargo:rustc-env=BUILD_DATE={now}"); diff --git a/compiler/erg_common/datetime.rs b/compiler/erg_common/datetime.rs index a3ec1bc1..df558f0c 100644 --- a/compiler/erg_common/datetime.rs +++ b/compiler/erg_common/datetime.rs @@ -13,8 +13,7 @@ pub fn now() -> String { .output() .expect("failed to execute process to get current time") }; - String::from_utf8(output.stdout.clone()) - .unwrap_or_else(|_| String::from_utf8_lossy(&output.stdout[..]).to_string()) + String::from_utf8_lossy(&output.stdout[..]) .trim_end() .to_string() } diff --git a/compiler/erg_common/python_util.rs b/compiler/erg_common/python_util.rs index 9bc3694d..d551c4e3 100644 --- a/compiler/erg_common/python_util.rs +++ b/compiler/erg_common/python_util.rs @@ -87,7 +87,7 @@ pub fn eval_pyc>(file: S) -> String { .expect("cannot execute python") }; let out = out.wait_with_output().expect("python doesn't work"); - String::from_utf8(out.stdout).expect("failed to decode python output") + String::from_utf8_lossy(&out.stdout).to_string() } pub fn exec_py(code: &str) {