Skip to content
14 changes: 12 additions & 2 deletions libs/@local/hashql/ast/src/lower/expander/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,19 @@ impl Display for FormatUserPath<'_, '_> {
fn format_absolute_path<'heap>(item: &Item<'heap>, registry: &ModuleRegistry<'heap>) -> String {
use core::iter;

let path = item.absolute_path(registry).into_iter().map(Symbol::unwrap);
#[expect(
clippy::needless_collect,
reason = "debugging code + required for reverse"
)]
let path: Vec<_> = item
.absolute_path_rev(registry)
.map(Symbol::unwrap)
.collect();

iter::once("").chain(path).intersperse("::").collect()
iter::once("")
.chain(path.into_iter().rev())
.intersperse("::")
.collect()
}

struct SpellingSuggestions<'heap, I> {
Expand Down
3 changes: 2 additions & 1 deletion libs/@local/hashql/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
step_trait,
sync_nonpoison,
try_trait_v2,
variant_count
variant_count,
maybe_uninit_fill
)]

extern crate alloc;
Expand Down
18 changes: 3 additions & 15 deletions libs/@local/hashql/core/src/module/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct Item<'heap> {
}

impl<'heap> Item<'heap> {
#[must_use]
pub fn ancestors(
&self,
registry: &ModuleRegistry<'heap>,
Expand All @@ -87,27 +88,14 @@ impl<'heap> Item<'heap> {
return None;
}

let module = registry.modules.index(next);
let module = registry.modules[next];
next = module.parent;

Some(module)
})
}

// TODO: deprecate
pub fn absolute_path(
&self,
registry: &ModuleRegistry<'heap>,
) -> impl IntoIterator<Item = Symbol<'heap>> {
let mut modules: Vec<_> = self.ancestors(registry).into_iter().collect();
modules.reverse();

modules
.into_iter()
.map(|module| module.name)
.chain(iter::once(self.name))
}

#[must_use]
pub fn absolute_path_rev(
&self,
registry: &ModuleRegistry<'heap>,
Expand Down
Loading
Loading