2 unstable releases
0.2.0 | Jun 19, 2020 |
---|---|
0.1.0 | Jun 17, 2020 |
#1882 in Development tools
19KB
372 lines
Obélix
Obélix is a tool to reduce Rust source files to produce MVEs.
Why use this tool?
Minimization is often useful to understand compiler errors. Isolating the errors and removing the noise is important and can help figuring out the problem. It's also important when asking questions on sites such as Stack Overflow or The Rust Programming Language Forum. This tools helps automating this process.
The intended usage of this tool is to help users produces minified source code to
- Help them understand why their code doesn't compile.
- Help them produce an MVE to ask a question on Stack Overflow, The Rust Programming Language Forum.
- Help them produce an MVE to open an issue on GitHub for compiler bugs.
Note that minimization isn't always perfect: When asking a question, having some context is sometimes useful. But Obélix can't know whether code is useless or intended to provide context. This means that there often would be a post-processing phase after using this tool.
How to use it
At the moment, Obélix has a very simple interface.
You can install it using cargo install obelix
. Just call obelix your-file.rs
and it will output a simpler producing the same errors as the original file, which you'll probably want to pipe into rustfmt
:
$ cat a.rs
fn main() {
error
}
fn unused() {}
$ rustc a.rs
error[E0425]: cannot find value `error` in this scope
--> a.rs:2:5
|
2 | error
| ^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
$ obelix a.rs | rustfmt
fn main() {
error
}
$ obelix a.rs | rustc -
error[E0425]: cannot find value `error` in this scope
--> <anon>:1:15
|
1 | fn main ( ) { error }
| ^^^^^ not found in this scope
error: aborting due to previous error
For more information about this error, try `rustc --explain E0425`.
Note that Obélix never overwrites your files.
Why “Obélix”?
I wanted to give this tool a name that would sound like "mini rust", or "mini-rs" or something. I eventually settled on menhir, which seemed like a good name especially with hir meaning long. Unfortunately the name was already reserved on crates.io. I therefore changed the name to Obélix, a menhir sculptor with a slight weight problem.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Obélix by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
All test files named so-ID
are user contributions from Stack Overflow and
are licenced under CC BY-SA. The
original post is accessible at https://stackoverflow.com/questions/$ID.
All test files named URLO-ID
are user contributions from The Rust Programming
Language Forum and are licensed under
CC BY-NC-SA 3.0. The original post is
accessible at https://users.rust-lang.org/t/$ID.
Menhir icon made by Good Ware from www.flaticon.com.
Dependencies
~3.5–5.5MB
~104K SLoC