Skip to content

Commit

Permalink
Better error output, and verusfmt before rustfmt (#23)
Browse files Browse the repository at this point in the history
## Quick Comparison

(Running on an obviously broken input)

### Before:
<img width="487" alt="image"
src="https://github.com/jaybosamiya/verusfmt/assets/5683582/479605ec-8849-4c0f-b077-a4dc76d6b7ff">

### After:
<img width="949" alt="image"
src="https://github.com/jaybosamiya/verusfmt/assets/5683582/89a8eb18-86c5-4038-ba8f-b67dfc7277fd">


## Details
* run verusfmt formatting before doing rustfmt; this allows us to give
more precise error locations in case of parse failures; the two
formatters should otherwise not interact with each other anyways, so the
choice of which one first was not a particularly critical decision
anyways (iirc)
* switch from [`anyhow`](https://github.com/dtolnay/anyhow/) to
[`miette`](https://github.com/zkat/miette) to enable nicer outputs
* start reporting the file name for the parse failure (fixes #20)
* produce nicer error output along with context lines
  • Loading branch information
parno authored Dec 29, 2023
2 parents b9af6df + 933f72b commit bf03155
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 30 deletions.
197 changes: 186 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ edition = "2021"
autoexamples = false

[dependencies]
anyhow = "1.0.71"
clap = { version = "4.3.11", features = ["derive"] }
fs-err = "2.9.0"
insta = "1.30.0"
itertools = "0.11.0"
miette = { version = "5.10.0", features = ["fancy"] }
pest = "2.0"
pest_derive = "2.0"
pretty = "0.12.1"
regex = "1.9.6"
similar = "2.2.1"
thiserror = "1.0.52"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17" }

Expand Down
Loading

0 comments on commit bf03155

Please sign in to comment.