summaryrefslogtreecommitdiff
path: root/src/errors
diff options
context:
space:
mode:
authorBen Bridle <ben@derelict.engineering>2025-04-27 12:38:40 +1200
committerBen Bridle <ben@derelict.engineering>2025-04-27 12:38:40 +1200
commitc13c1f2748598343e01128c3f734df309aa4a26d (patch)
tree0fdef6bbdac5e32031ea90146ad030d4892e260a /src/errors
parent55e64d35273a425b52b7d913b9368af2f0370bbb (diff)
downloadassembler-c13c1f2748598343e01128c3f734df309aa4a26d.zip
Replace ansi library with inked library
The inked library handles colours correctly on Windows. The log library has also been updated to the newer version which uses inked internally.
Diffstat (limited to 'src/errors')
-rw-r--r--src/errors/merge_error.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/errors/merge_error.rs b/src/errors/merge_error.rs
index 89f55a2..01cbcba 100644
--- a/src/errors/merge_error.rs
+++ b/src/errors/merge_error.rs
@@ -1,8 +1,5 @@
use crate::*;
-use ansi::*;
-use log::error;
-
use std::collections::HashSet;
@@ -14,15 +11,19 @@ pub struct MergeError<'a> {
impl MergeError<'_> {
pub fn report(&self) {
- error!("A cyclic dependency was found between the following files:");
+ let message = "A cyclic dependency was found between the following files:";
+ let mut details = InkedString::new();
for id in &self.cyclic_unit_ids {
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}"),
+ Some(name) => {
+ details.push(ink!("{name}"));
+ details.push(ink!(" ({path})\n").dim());
+ }
+ None => {
+ details.push(ink!("{path}\n"));
+ }
};
// Print each parent involved in the dependency cycle.
for parent_id in &unit.parent_ids {
@@ -30,10 +31,13 @@ impl MergeError<'_> {
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!(" => {parent_path}"),
+ Some(parent_name) => {
+ details.push(ink!(" => {parent_name}"));
+ details.push(ink!(" ({parent_path})\n").dim());
+ }
+ None => {
+ details.push(ink!(" => {parent_path}\n"));
+ }
};
// Report all referenced symbols that are defined by this parent.
let mut reported_definition_ids = HashSet::new();
@@ -42,12 +46,13 @@ impl MergeError<'_> {
if reported_definition_ids.insert(reference.definition) {
let definition = &self.resolver.definitions[reference.definition];
if definition.tracked.source_id == *parent_id {
- eprintln!(" {:?}", definition.tracked.symbol);
+ details.push(ink!(" {:?}\n", definition.tracked.symbol));
}
}
}
}
}
}
+ log_error(message, Some(details));
}
}