diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/errors/merge_error.rs | 36 | ||||
-rw-r--r-- | src/reports/source_hierarchy.rs | 39 |
2 files changed, 35 insertions, 40 deletions
diff --git a/src/errors/merge_error.rs b/src/errors/merge_error.rs index a694b71..3ff60d2 100644 --- a/src/errors/merge_error.rs +++ b/src/errors/merge_error.rs @@ -14,27 +14,25 @@ impl MergeError<'_> { pub fn report(&self) { error!("A cyclic dependency was found between the following libraries:"); for id in &self.cyclic_unit_ids { - if let Some(unit) = self.resolver.source_units.get(*id) { - let path = &unit.source_unit.path(); - match unit.source_unit.name() { - Some(name) => - eprintln!("{name}{NORMAL}{DIM} ({path}){NORMAL}"), + let unit = &self.resolver.source_units[*id]; + let path = &unit.source_unit.path(); + match unit.source_unit.name() { + Some(name) => + eprintln!("{name}{NORMAL}{DIM} ({path}){NORMAL}"), + None => + eprintln!("{path}"), + }; + // Print each parent involved in the dependency cycle. + for parent_id in &unit.parent_ids { + if !self.cyclic_unit_ids.contains(parent_id) { continue; } + let parent_unit = &self.resolver.source_units[*parent_id]; + let parent_path = &parent_unit.source_unit.path(); + match parent_unit.source_unit.name() { + Some(parent_name) => + eprintln!(" => {parent_name} {DIM}({parent_path}){NORMAL}"), None => - eprintln!("{path}"), + eprintln!(" => {parent_path}"), }; - // Print each parent involved in the dependency cycle. - for parent_id in &unit.parent_ids { - if !self.cyclic_unit_ids.contains(parent_id) { continue; } - if let Some(parent_unit) = self.resolver.source_units.get(*parent_id) { - let parent_path = &parent_unit.source_unit.path(); - match parent_unit.source_unit.name() { - Some(parent_name) => - eprintln!(" => {parent_name} {DIM}({parent_path}){NORMAL}"), - None => - eprintln!(" => {parent_path}"), - }; - } - } } } } diff --git a/src/reports/source_hierarchy.rs b/src/reports/source_hierarchy.rs index 9478c56..39550ab 100644 --- a/src/reports/source_hierarchy.rs +++ b/src/reports/source_hierarchy.rs @@ -30,29 +30,26 @@ impl<'a> SourceHierarchy<'a> { false => eprint!("├── "), true => eprint!("└── "), } - if let Some(unit) = self.resolver.source_units.get(id) { - let path_str = &unit.source_unit.main.path.as_os_str().to_string_lossy(); - if let Some(name_str) = unit.source_unit.name() { - eprint!("{name_str}{BLUE}"); - if unit.source_unit.head.is_some() { eprint!(" +head") } - if unit.source_unit.tail.is_some() { eprint!(" +tail") } - let mut unresolved = 0; - for symbol in &self.resolver.unresolved { - if symbol.source_id == id { unresolved += 1; } - } - if unresolved > 0 { eprint!("{RED} ({unresolved})"); } - eprintln!("{NORMAL} {DIM}({path_str}){NORMAL}"); - } else { - eprintln!("{path_str}"); - } - levels.push(end); - let len = unit.child_ids.len(); - for (i, id) in unit.child_ids.iter().enumerate() { - let end = i + 1 == len; - self.report_leaf(*id, levels.clone(), end); + let unit = &self.resolver.source_units[id]; + let path_str = &unit.source_unit.main.path.as_os_str().to_string_lossy(); + if let Some(name_str) = unit.source_unit.name() { + eprint!("{name_str}{BLUE}"); + if unit.source_unit.head.is_some() { eprint!(" +head") } + if unit.source_unit.tail.is_some() { eprint!(" +tail") } + let mut unresolved = 0; + for symbol in &self.resolver.unresolved { + if symbol.source_id == id { unresolved += 1; } } + if unresolved > 0 { eprint!("{RED} ({unresolved})"); } + eprintln!("{NORMAL} {DIM}({path_str}){NORMAL}"); } else { - eprintln!("<error loading source unit details>"); + eprintln!("{path_str}"); + } + levels.push(end); + let len = unit.child_ids.len(); + for (i, id) in unit.child_ids.iter().enumerate() { + let end = i + 1 == len; + self.report_leaf(*id, levels.clone(), end); } } } |