Skip to content
17 changes: 16 additions & 1 deletion gix-error/src/exn/impls.rs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I know gix-error has to wrap once more the inner error into Untyped because downcast must have the type param matched. In this case, it seems to be inevitable.

Copy link
Member

@Byron Byron Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, the into_inner() and into_box() can be removed as there is always gix_error::Error to hold these types.

Let's leave it as is for now, and I will consider removing them to avoid that double-box.

Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,23 @@ impl<E: Error + Send + Sync + 'static> Exn<E> {

/// Erase the type of this instance and turn it into a bare `Exn`.
pub fn erased(self) -> Exn {
let untyped_frame = {
let Frame {
error,
location,
children,
} = *self.frame;
// Unfortunately, we have to double-box here.
// TODO: figure out tricks to make this unnecessary.
let error = Untyped(error);
Frame {
error: Box::new(error),
location,
children,
}
};
Exn {
frame: self.frame,
frame: Box::new(untyped_frame),
phantom: Default::default(),
}
}
Expand Down