Commit Graph

76 Commits

Author SHA1 Message Date
François Garillot 18c217f0dc
Add CI job for no-std build verification and fix Infallible StdError implementation
- Add dedicated no-std CI job that builds for wasm32-unknown-unknown target
- Fix Infallible StdError implementation for no-std environments

The CI job validates:
1. Core no-std functionality (no default features)
2. fancy-no-syscall feature set compatible with no-std environments
2025-10-21 07:19:26 -04:00
François Garillot 79fbd0a07d
feat(no_std): Implement comprehensive no_std support
This commit finishes full no_std support to miette.
2025-10-21 07:19:03 -04:00
cgettys-microsoft 2b79495c79
fix(ci, clippy): raise MSRV to 1.82, fix rust 1.90 warnings (#451)
* fix: remove unused code

* fix: 1.90 errors

* MSRV: 1.82.0

* fix: warnings exposed by increasing MSRV
2025-09-29 09:43:02 -07:00
Elijah Hartvigsen f2ef693d1c
feat(labels): add support for disabling the primary label line/col information (#419) 2025-03-01 17:56:47 -08:00
unbyte 1e1938a099
fix(graphical): prevent leading newline when no link/code (#418) 2025-01-14 14:01:44 -08:00
ElKowar 771a07519f
feat(graphical): support rendering related diagnostics as nested (#417)
Fixes: https://github.com/zkat/miette/issues/416
2024-12-22 14:06:11 -08:00
George Pollard 465e6b6ab6
feat(graphical): Inherit source code to causes (#401) 2024-11-26 19:53:19 -08:00
Bruce Mitchener d60c8f10f1
docs: Fix some broken links and missing backticks. (#399) 2024-09-25 10:29:12 -07:00
Bruce Mitchener 215f9aae33
docs: Fix typos (#398) 2024-09-25 10:28:30 -07:00
George Pollard d6b4558502
fix(graphical): Handle invalid UTF-8 in source code (#393)
* Handle invalid unicode in source

* Fix build on 1.70
2024-08-08 14:46:42 -07:00
Jonathan Dygert bf5aa3742f
fix(graphical): Format entire link instead of just name (#389) 2024-07-11 16:04:28 -07:00
Dániel Buga edfdcb525e
fix(handlers): Disable textwrap::smawk feature (#379) 2024-06-26 09:34:30 -07:00
Luca Bruno b8dfcda4a8
perf(handlers): optimize string-buffer reallocations (#387)
This improves `get_lines()` logic by using a string-buffer with a capacity hint.
That avoids growing the buffer from zero each time, saving a bunch of reallocations.
2024-06-26 09:31:31 -07:00
Boshen e1026f75e0
fix(clippy): fix Rust v1.78.0 clippy warnings (#382) 2024-06-26 09:31:12 -07:00
Brooks Rady 3eabbcebf1
fix(graphical): fix nested error wrapping (#358)
Fixes: https://github.com/zkat/miette/issues/333
2024-03-27 16:20:06 -07:00
Nahor 7d9dfc6e8e
fix(invalid span): skip the snippet when read_span fails (#347)
Fixes: https://github.com/zkat/miette/issues/219

When a snippet couldn't be read (typically because the span didn't fit
within the source code), it and the rest of the diagnostic were silently
dropped, which was confusing to the developer.
Now, in place of the snippet, print an error message with the name of
the failed label and the error it triggered, then proceed with the rest
of the diagnostic (footer, related, ...)
2024-02-21 13:46:58 -08:00
David Calavera c7144ee513
feat(fancy): Add option to change the link display text (#335)
This option allows to globally change the default `(link)` display text with any other text provider by users.
2024-02-04 16:54:18 -08:00
Adam Curtis e65d0a78cc
feat(highlighting): add syntax highlighting support with syntect crate (#313) 2024-02-03 19:47:46 -08:00
Brooks Rady cb2ae2e18b
fix(graphical): render cause chains for inner errors (#330)
The default `GraphicalReportHandler` disables the printing of cause
chains for any inner errors (errors `related()` to a source diagnostic)
when it disables nested footer printing. This results in lost cause
chain information when printing with the default report handler.
2024-01-30 16:03:01 -08:00
Hytak 19c22143cb
feat(graphical): render disjoint snippets separately for cleaner output (#324) 2024-01-11 10:42:32 -08:00
Zanie Blue b0744462ad
feat(graphical): Add `wrap_lines: bool` option allowing wrapping be disabled entirely (#328) 2024-01-04 10:44:52 -08:00
Jonathan Dönszelmann 7ff4f874d6
fix(graphical): rendering bug on small spans in large spans (#316)
Fixes: https://github.com/zkat/miette/issues/317

It turned out there were two really. One related to how many characters
were added for the arrowheads in the gutter, and one where the gutter
was extended to a number of characters, including ansi escape codes.
However, because ansi escape codes are rather big, there would never be
any extension since the system thought the string was already long
enough, even though you don't actually see the width of those codes.
2023-11-15 11:40:16 -08:00
Jonathan Dönszelmann 865d67c8dd
feat(graphical): support rendering labels that contain newlines (#318)
Fixes: https://github.com/zkat/miette/issues/85
2023-11-15 10:39:29 -08:00
Zanie Blue fd77257cee
feat(graphical): Expose additional `textwrap` options (#321) 2023-11-15 10:34:24 -08:00
Benjamin Lee 3d6f903df0
fix(formatting): Fix formatting bug when an empty span is not aligned to a char boundary (#314)
Previous output looked like this:

---- single_line_with_wide_char_unaligned_span_empty stdout ----
Error: oops::my::bad

  × oops!
   ╭─[bad_file.rs:2:4]
 1 │ source
 2 │   👼🏼text
   ·   ─▲
   ·    ╰── this bit here
 3 │     here
   ╰────
  help: try doing it better next time?

Note that the .max(start + 1) term is still necessary in the nonempty
branch, since it's possible to have a nonempty span covering zero-width
text.

* remove uncessary if statement

start > end in all cases.
2023-11-09 13:21:32 -08:00
Matt a8b4ae012a
fix(graphical): Extend error text span to whole code points (#312)
Fixes: https://github.com/zkat/miette/issues/223

This fixes a panic when an error starts inside a Unicode code point. The
range is extended to start (or end) at the beginning (or end) of the
character inside which the byte offset is located.
2023-11-02 09:33:55 -07:00
Bruce Mitchener 06b348230a
fix(clippy): Add missing semicolons where nothing is returned. (#293) 2023-09-25 10:33:07 -07:00
Will Crichton db0b7e403a
feat(labels): Add support for primary label in specifying line/col information (#291) 2023-09-20 15:36:33 -07:00
Bruce Mitchener cc81382a60
fix(misc): Improve ci and fix clippy (#290)
* ci: Update actions, replace actions-rs.

* `actions/checkout` is updated from `v1` to the current `v4`.
* `actions-rs/toolchain` is replaced by `dtolnay/rust-toolchain` as
  the `actions-rs` actions haven't been maintained in a long time.

* clippy: Remove unnecessary call to `into_iter`.

The parameter takes `IntoIterator`, so we don't have to call
`into_iter` at the call site.

* clippy: Remove explicit lifetime that can be elided.

* clippy: tests: Fix useless conversion warnings.

* clippy: tests: Remove call to `format!`.

* Fix minimal-versions build.

Due to changes in the nightly compiler, using a recent nightly
requires proc-macro2 1.0.60 or later:

https://github.com/dtolnay/proc-macro2/issues/356

* ci: Use is-terminal 0.4.7 for MSRV builds.

is-terminal 0.4.8 updated its MSRV to 1.63, so we can't use it
with our MSRV of 1.56. Force usage of the older version which has
an older MSRV.
2023-09-20 10:37:40 -07:00
Marcel Müller aefe323780
feat(nested): Render inner diagnostics (#170) 2023-05-18 15:41:17 -07:00
Alexander Seiler 675f3411e3
fix(misc): Correct some typos (#255)
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-04-25 21:07:18 -07:00
Yoni Feng 566d6be6e3
misc(perf): nit perf improvements (#244) 2023-03-29 20:21:40 -07:00
dalance 3497508aa9
fix(graphical): Fix wrong severity of related errors (#234) 2023-02-08 16:26:27 -08:00
Benjamin Lee 8b56d277ef
fix(graphical): Fix panic with span extending past end of line (#221)
Fixes: #215 

This also changes the behavior with spans including a CRLF line-ending.
Before the panic bug was introduced, these were rendered with the CRLF
being two visual columns wide. Now, any span extending past the EOL is
treated as including one extra visual column.
2022-11-23 16:35:13 -08:00
Benjamin Lee b8810ee3d8
fix(graphical): Fix panic with zero-width span at end of line (#204)
This was introduced in 196c09ce7a, and is
a simple off-by-one error.
2022-10-28 16:20:10 -07:00
Benjamin Lee 196c09ce7a
fix(graphical): Align highlights correctly with wide unicode characters and tabs (#202)
Fixes: https://github.com/zkat/miette/issues/97
Fixes: https://github.com/zkat/miette/issues/87

Tabs are always expanded to spaces by the graphical handler, and `tab_width` now defaults to 4. Instead of replacing every tab with a fixed number of spaces, spaces are used to align to the next tabstop. `tab_width` controls the space between tabstops rather than the fixed width of each tab character.

Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
2022-09-10 14:20:37 -07:00
Luca Palmieri b9ea587159
feat(graphical): Allow miette users to opt-out of the rendering of the cause chain (#192)
Fixes: https://github.com/zkat/miette/issues/191
2022-08-09 17:32:02 -07:00
Rain 12dc40070a
fix(graphical): handle an empty source (#183)
In some cases the source can be completely empty -- handle that in a reasonable fashion.
2022-07-08 19:41:12 -07:00
Matthias Beyer bc449c8426
feat(diagnostic_source): add protocol method for Diagnostic-aware source chaining (#165)
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2022-05-05 08:32:37 -07:00
Kat Marchán 1a36fa7ec8
fix(graphical): fix issue with duplicate labels when span len is 0 (#159)
Fixes: https://github.com/zkat/miette/issues/130
2022-04-22 19:31:51 -07:00
Kat Marchán 084ed138b7
feat(related): print related prefixes according to severity (#158)
Fixes: https://github.com/zkat/miette/issues/139
2022-04-22 18:55:45 -07:00
Kat Marchán 23ee3642d1
feat(labels): allow optional labels in derive macro (#153)
Fixes: https://github.com/zkat/miette/issues/110
2022-04-17 19:41:10 -07:00
Kat Marchán 37cda4a3a4
fix(fmt): cargo fmt 2022-04-03 20:31:18 -07:00
Kat Marchán b98b098282
fix(clippy): misc clippy fixes 2022-04-03 18:33:51 -07:00
Christopher Durham b6a6cc9e75
feat(reporter): Allow GraphicalReportHandler to disable url display (#137) 2022-03-18 16:28:54 -07:00
Moritz Mœller 5d23c0d61d
fix(docs): Docs overhaul (#124)
* Fixed/formatted all intradoc links. Various other small doc fixes/typography/etc.

* Clarified semantic similarity with anyhow/eyre types/macros.

* Removed unused MietteError::SetPrinterFailure.

* README now generaed from lib.rs via `cargo readme`.

* More doc fixes, made ErrorHook type public.

* Indentation (docs).
2022-02-25 08:39:18 -08:00
Paul Colomiets 3a17fceabb feat(handlers): propagate source code to related errors
Fixes #99
2022-02-19 16:58:48 -08:00
Kirill Vasiltsov 1f70140c2e
feat(tabs): Add replace tabs with spaces option (#82)
Fixes: https://github.com/zkat/miette/issues/73
2021-10-05 21:05:57 -07:00
Kat Marchán 612967d381 fix(deps): remove dep on itertools 2021-09-22 16:34:21 -07:00
Kat Marchán 77c5899bbd fix(graphical): render URLs even without a code 2021-09-22 16:34:21 -07:00