Commit Graph

555 Commits

Author SHA1 Message Date
Brooks Rady 916241b4f9
Merge a8cb8fa340 into b466948965 2026-06-03 13:58:10 +09:00
Kat Marchán b466948965
docs: Create AGENTS.md 2026-06-01 11:20:27 -07:00
cgettys-microsoft df7bcfa17d
feat(etc): Add MietteSpanContents::with_name, improve docs, fix tests being compiled in downstream libraries, fix NamedSource's Debug impl (#450)
* fix: remove unused code

* fix: 1.90 errors

* MSRV: 1.82.0

* fix: warnings exposed by increasing MSRV
2025-09-29 09:43:46 -07: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
Expyron 7a4d759c59
fix(deps): Use const init for Mutex (#447) 2025-09-25 21:12:37 -07:00
Louis Maddox fea8043b3e
chore: update unicode-width dependency to v0.2.0 (#439) 2025-09-25 21:11:50 -07:00
Daniel Levin 51ca022b1f
docs: Include #[diagnostic(forward(..)] in documentation (#446) 2025-09-25 21:11:28 -07:00
Kat Marchán 907857058d
chore: Release 2025-04-26 21:52:05 -07:00
Kat Marchán 34b8774b36
docs: update changelog 2025-04-26 21:47:25 -07:00
Brooks Rady 521ef91f77
fix(deps): miette can now be used without syn (#436)
* style(clippy): quickly fix up clippy lints

* refactor(miette): remove `thiserror` from `error.rs`

* fix(fancy): `fancy` no longer depends on `derive`

Before this change, the `fancy` feature required the `derive` feature to
compile. Despite this, `derive` was not listed as a required feature to
use `fancy`. This meant that building with:
`cargo build --no-default-features --features fancy` would result in a
compilation error!

Now `fancy` can be used without `derive` enabled, and another use of
`thiserror` has been removed!

* refactor(miette): remove `thiserror` from `into_diagnostic.rs`

* refactor(miette): reuse `DiagnosticError` in `protocol.rs`

* refactor(miette): make `thiserror` a dev-dependency

* fix(miette): correctly forward error sources

* fix(miette): match `TestError` visibility with `mod tests`

* fix(miette): maintain 1.70 MSRV

* fix(miette): another fix for MSRV 1.70

* docs(miette): sync README and `rustdoc`
2025-04-26 11:34:21 -07:00
nogiro 59c81617de
feat(deps): update `thiserror` from 1.0.56 to 2.0.11 (#426) 2025-03-01 18:04:51 -08:00
Gabriel Levcovitz 58d9f12411
fix(highlight): increase syntax highlighter config priority (#424)
Fixes: https://github.com/zkat/miette/issues/337
2025-03-01 17:58:58 -08: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
bohan a93afcf7e3
docs: introduce primary param in label (#413) 2025-03-01 17:55:37 -08:00
Gabriel Levcovitz 9ba6fad769
fix(clippy): elide lifetimes (#423) 2025-03-01 17:52:07 -08:00
Kat Marchán b8c144f2a6
(cargo-release) version 7.5.0 2025-01-31 18:50:56 -08:00
Kat Marchán 429ca37d8d
(cargo-release) version 7.5.0 2025-01-31 18:50:56 -08:00
Kat Marchán b4c983a393
docs: update changelog 2025-01-31 18:50:19 -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
Akiomi KAMAKURA c7eeada1e0
docs: fix broken link (#415) 2024-12-08 09:33:24 -08:00
Kat Marchán b2011f693b
chore: Release 2024-11-26 20:01:39 -08:00
Kat Marchán 0c46c0b4d4
docs: update changelog 2024-11-26 20:00:13 -08:00
Jalil David Salamé Messina 7fae60fd84
feat(report): Implement `WrapError` for `Option` (#409)
Fixes: https://github.com/zkat/miette/issues/408

Implement `WrapError` for `Option<T>`. This is inline with `anyhow` that
also implements `Context` for `Option<T>`.

The implementation requires us to introduce a `DisplayError` internal
only type, that creates an error from a type that only implements
`Display` (`Report::from_adhoc` requires the type to also implement
`Debug`, but `WrapError` only requires it to implement `Display`).

For this I copied `MessageError` and adapted it to implement `Debug`
using the underlying type's `Display` impl. This is a bit of a hack, but
anyhow does [something similar][1].

[1]: https://docs.rs/anyhow/latest/src/anyhow/wrapper.rs.html#34
2024-11-26 19:55:24 -08:00
George Pollard 465e6b6ab6
feat(graphical): Inherit source code to causes (#401) 2024-11-26 19:53:19 -08:00
Фаттахов Марат Русланович 68d47fa8b5
tests: Small refactor of doc tests (#396)
Move use NamedSource a bit up, since now it looks like it is not
imported.

Co-authored-by: Marat Fattakhov <m.fattakhov@yadro.com>
2024-11-26 19:50:56 -08:00
Kat Marchán 01564e070f
chore: Release 2024-11-26 00:44:33 -08:00
Kat Marchán fe068f6fc1
docs: update changelog 2024-11-26 00:43:02 -08:00
Gal Schlezinger 2902a2337c
docs(examples): add serde_json integration example (#407) 2024-11-13 09:57:24 -08:00
Bruce Mitchener 5f441d0115
fix(clippy): Fix `needless_return` lint. (#405)
This happens when building with `--features fancy`.
2024-09-26 09:32:58 -07:00
Cass Fridkin f3fb4c1ecd
feat(Diagnostic): Implement `Diagnostic` for `Infallible` (#402) 2024-09-25 10:30:33 -07: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
Bruce Mitchener 789a04e30d
fix(features): Use `dep:` syntax for dependencies in features. (#394)
This prevents creating implicit features for them which can be
confusing (and duplicates features).
2024-09-25 10:28:01 -07:00
Bruce Mitchener 21e9a70ad8
deps: Bump `terminal_size` to 0.4.0 (#404) 2024-09-25 10:14:22 -07:00
John Lewis 93d3bd118a
feat(Report): add `from_err()` method to `Report` (#403) 2024-09-06 23:56:01 -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
Bruce Mitchener 15beec4330
fix(clippy): fix `clippy::doc_lazy_continuation` lints (#395)
* Fix `clippy::doc_lazy_continuation` lints

* Fix `dead_code` warnings in tests.

Protect code used in some tests based on features with feature
checks.

* Fix `clippy::needless_borrows_for_generic_args` lints

* Remove a useless conversion

* Remove a cfg_attr check for `track_caller`

This shouldn't be needed here as the test is already ignored.
2024-08-06 10:12:06 -07:00
Jonathan Dygert bf5aa3742f
fix(graphical): Format entire link instead of just name (#389) 2024-07-11 16:04:28 -07:00
Brooks Rady bdd1d74614
fix(report): conversion into `Box<dyn Diagnostic>` (#370)
Fixes: https://github.com/zkat/miette/issues/369

Diagnostic impls are no longer reset to default when converting a
`Report` into a `Box<dyn Diagnostic>`. Also prevented `Report` vtables
and handlers from being kept around on the heap after conversion.
2024-06-26 09:36:46 -07:00
Dániel Buga edfdcb525e
fix(handlers): Disable textwrap::smawk feature (#379) 2024-06-26 09:34:30 -07:00
Rintaro Itokawa 9bbcf3c601
fix(perf): mark error constructors cold (#378)
* refactor: mark error constructors cold

* refactor: remove `Send + Sync` impl
2024-06-26 09:33:42 -07:00
Benjamin Lee 73da45b65c
feat(SourceSpan): add impl From<InclusiveRange> (#385)
This can be used to avoid awkward `start..(end + 1)` constructions,
which will trigger the `clippy::range_plus_one` lint.

I added a single impl for `InclusiveRange` rather than a blanket
`impl<T: RangeBounds> From<T> for SourceSpan` for two reasons. The first
is that the blanket impl would be a breaking change (because dependent
crates may currently define a type `T: RangeBounds` and also have `impl
From<T> for SourceSpan`). The second is that this would allow one-sided
ranges (`..x`, `x..`). In order to support bounded-below ranges, we
would need to change `SourceSpan` so that `length` may depend on the the
specific `SourceCode` instance. That seems like an unlikely use case.
2024-06-26 09:31:50 -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
Boshen 813232ba79
fix(color): setting NO_COLOR should not print ansi codes for non-terminals (#381)
Fixes: https://github.com/zkat/miette/issues/380
2024-06-11 09:18:24 -07:00
Sébastien Mischler b82cc81b8e
fix(docs): `alt` attribut for `single-line-example.png` (#372)
* fix(docs): `alt` attribut for `single-line-example.png`

The white line breaks in the `alt` attribute prevented the `single-line-example.png` image from being displayed.

* Revert "fix(docs): `alt` attribut for `single-line-example.png`"

This reverts commit 2e97d568aa.

* fix: image link in `lib.rs` instead of `readme.md`

* feat(docs): cargo make readme
2024-05-01 15:20:01 -07:00
Brooks J Rady a8cb8fa340 feat!(blanket_impls): impl `Diagnostic` for &T and Box<T>
Brings things in line with best practices as described in "Rust for
Rustaceans" when it comes to "Ergonomic Trait Implementations" in Chapter
3. Practically means that people can pass more types to any functions
taking either `dyn Diagnostic` or `impl Diagnostic`.

BREAKING CHANGE: Added blanket impls may overlap with manual user impls.
If these impls are just hacks to achieve the same as the blanket ones do,
then they can simply be removed. If the impls for `T` and `&T` differ
semantically, then the user would need to employ the newtype pattern to
avoid overlap.
2024-04-23 16:36:56 -07:00
Will Bush ea4296dace
fix(clippy): Fix clippy lints in docs (#365)
* Fix commented out code in lib.rs docs not found in README.md

* Fix clippy lints in README.md and lib.rs
2024-04-12 23:11:30 -07:00
TrapinchO 97766e8d90
docs: fix up previous docs change a bit (#362) 2024-04-03 14:58:36 -07:00