]> git.lizzy.rs Git - rust.git/commitdiff
Fix debuginfo generation when given source path doesn't contain a dir (eg plain lib.rs)
authorbjorn3 <bjorn3@users.noreply.github.com>
Tue, 11 Jun 2019 16:40:07 +0000 (18:40 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Wed, 12 Jun 2019 16:30:27 +0000 (18:30 +0200)
src/debuginfo.rs

index 0e9846807021188a0e56474ddcef27b33907951d..e379a7829f465ecc10e86554cbaa0dbda58ff2f3 100644 (file)
@@ -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(),