diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 2eaaf127e41ea..35b34663a4714 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -643,10 +643,10 @@ fn create_file<'ll>( builder, file_name.as_c_char_ptr(), file_name.len(), - directory.as_c_char_ptr(), + if directory.is_empty() { ptr::null() } else { directory.as_c_char_ptr() }, directory.len(), hash_kind, - hash_value.as_c_char_ptr(), + if hash_value.is_empty() { ptr::null() } else { hash_value.as_c_char_ptr() }, hash_value.len(), source.map_or(ptr::null(), |x| x.as_c_char_ptr()), source.map_or(0, |x| x.len()),