bytecodealliance / bytecodealliance/wasmtime

CodegenError should have optional context, rather than pretty-ifying it into a string

Open
#2,204 8 comments 0 reactions 0 assignees View on GitHub
cranelift cranelift:E-easy
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 18h
Merged PRs (30d)
126

Description

`pretty_error` should be replaced with methods on `CodegenError` that mutate the error and provide the context that `pretty_error` otherwise adds, and the `CodegenError`'s `Display` impl should print what `pretty_error` creates when it has the necessary context.

These context-adding methods would be similar to how the `wast` crate adds file contents and filename context to errors with these methods:

* https://docs.rs/wast/24.0.0/wast/struct.Error.html#method.set_text
* https://docs.rs/wast/24.0.0/wast/struct.Error.html#method.set_path

Then we can delete `pretty_error`, and avoid using string as an error type in more places (notably in `cranelift-filetests` and its `pretty_anyhow_error` workaround).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.