From 28fc2063873438802b7e5912d7811ff7cd3bd5c6 Mon Sep 17 00:00:00 2001 From: rootile Date: Fri, 10 Jul 2026 18:14:25 +0200 Subject: [PATCH] rust: add rootcause as error library Change-Id: I65460dda21331d79f0dfadfe06a7d6738c9ddefe --- Cargo.lock | 37 ++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + lix/lix-rs/Cargo.toml | 3 ++- lix/lix-rs/main.zng | 1 + lix/lix-rs/rootcause.zng | 10 ++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 lix/lix-rs/rootcause.zng diff --git a/Cargo.lock b/Cargo.lock index ef8364a0c..6e7bf5f0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -452,6 +452,7 @@ version = "0.0.0" dependencies = [ "lix-doc", "regex", + "rootcause", "rustyline", "rustyline-derive", "zngur", @@ -660,6 +661,28 @@ dependencies = [ "rowan", ] +[[package]] +name = "rootcause" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b660d9968fae12f4e691f2b2be5d9a3a6de875300c682e8d2cb89a618dd60875" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rootcause-internals", + "rustc-hash 2.1.3", + "triomphe", +] + +[[package]] +name = "rootcause-internals" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0184f6fcff3b58b7c963aee6e3cc915c04331aa6eef974f79d7d44d21e246c24" +dependencies = [ + "triomphe", +] + [[package]] name = "rowan" version = "0.15.16" @@ -668,7 +691,7 @@ checksum = "0a542b0253fa46e632d27a1dc5cf7b930de4df8659dc6e720b647fc72147ae3d" dependencies = [ "countme", "hashbrown 0.14.5", - "rustc-hash", + "rustc-hash 1.1.0", "text-size", ] @@ -678,6 +701,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + [[package]] name = "rustyline" version = "18.0.1" @@ -799,6 +828,12 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" +[[package]] +name = "triomphe" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b40688ea6389c8171614b25491f71d4a27946e0c7ce2da1c6de27e25abf1a0ae" + [[package]] name = "typenum" version = "1.20.1" diff --git a/Cargo.toml b/Cargo.toml index bada976dc..a73c15ba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" [workspace.dependencies] clap = "4" regex = "1.12.4" +rootcause = "0.13.0" rustyline = "18" rustyline-derive = "0.12" syn = "2.0" diff --git a/lix/lix-rs/Cargo.toml b/lix/lix-rs/Cargo.toml index 96fce17a8..2bd2ed0bf 100644 --- a/lix/lix-rs/Cargo.toml +++ b/lix/lix-rs/Cargo.toml @@ -12,7 +12,8 @@ default = [] [dependencies] lix-doc.path = "../lix-doc" -regex.workspace=true +regex.workspace = true +rootcause.workspace=true rustyline.workspace = true rustyline-derive.workspace = true diff --git a/lix/lix-rs/main.zng b/lix/lix-rs/main.zng index b16af6f4c..995bbf77d 100644 --- a/lix/lix-rs/main.zng +++ b/lix/lix-rs/main.zng @@ -13,6 +13,7 @@ // in a readable and maintainable state without scattering bits of types all over the place. merge "./primitives.zng"; +merge "./rootcause.zng"; merge "./std-common.zng"; merge "./tuples.zng"; diff --git a/lix/lix-rs/rootcause.zng b/lix/lix-rs/rootcause.zng new file mode 100644 index 000000000..ef598b2de --- /dev/null +++ b/lix/lix-rs/rootcause.zng @@ -0,0 +1,10 @@ +use ::rootcause::Report as Report; + +mod ::rootcause { + type Report { + #layout_conservative(size = 8, align = 8); + wellknown_traits(Debug); + + fn to_string(&self) -> ::std::string::String; + } +}