From 5e2ea4f1943067c04e6f76db81c81f8cbb381b52 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 11 Jun 2019 18:40:07 +0200 Subject: [PATCH] Fix debuginfo generation when given source path doesn't contain a dir (eg plain lib.rs) --- src/debuginfo.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/debuginfo.rs b/src/debuginfo.rs index 0e984680702..e379a7829f4 100644 --- a/src/debuginfo.rs +++ b/src/debuginfo.rs @@ -28,12 +28,17 @@ fn line_program_add_file( ) -> FileId { match file { FileName::Real(path) => { - let dir_name = LineString::new( - path.parent().unwrap().to_str().unwrap().as_bytes(), - line_program.encoding(), - line_strings, - ); - let dir_id = line_program.add_directory(dir_name); + let dir_name = path.parent().unwrap().to_str().unwrap().as_bytes(); + let dir_id = if !dir_name.is_empty() { + let dir_name = LineString::new( + dir_name, + line_program.encoding(), + line_strings, + ); + line_program.add_directory(dir_name) + } else { + line_program.default_directory() + }; let file_name = LineString::new( path.file_name().unwrap().to_str().unwrap().as_bytes(), line_program.encoding(),