From a7f695dbae85483b4c2362bcc7e72e267b719093 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 10 Aug 2020 23:02:43 +0100 Subject: [PATCH] FFI: Fix tracing log path handling on Windows Windows uses u16 for OS strings, requiring an owned OsString when converting to Rust. This needs to be stored in its own variable, so we can take an immutable reference to it in Path::new. --- src/rust/src/tracing_ffi.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rust/src/tracing_ffi.rs b/src/rust/src/tracing_ffi.rs index 2f7ecf731..cd2466b6d 100644 --- a/src/rust/src/tracing_ffi.rs +++ b/src/rust/src/tracing_ffi.rs @@ -68,12 +68,12 @@ pub extern "C" fn tracing_init( let log_path = unsafe { slice::from_raw_parts(log_path, log_path_len) }; #[cfg(not(target_os = "windows"))] - let log_path = Path::new(OsStr::from_bytes(log_path)); + let log_path = OsStr::from_bytes(log_path); #[cfg(target_os = "windows")] - let log_path = Path::new(OsString::from_wide(log_path)); + let log_path = OsString::from_wide(log_path); - tracing_init_file(log_path, initial_filter, log_timestamps) + tracing_init_file(Path::new(&log_path), initial_filter, log_timestamps) } }