Commit Graph

59 Commits

Author SHA1 Message Date
Nahor 03060245d8
feat(collection): add support for collection of labels (#341)
Fixes: https://github.com/zkat/miette/issues/315

Allow errors to have a number of labels determined at runtime.
An example of this is when the rust compiler labels all the arms of
a `match` expression when one of them has an incompatible type

To allow customization of the text for each label in a collection, add
support for using LabeledSpan in collections instead of just regular
spans
2024-02-15 18:14:04 -08:00
Brooks Rady 6f09250cca
feat(source): derive common traits for NamedSource, SourceSpan, and SourceOffset (#340) 2024-02-08 14:16:49 -08:00
Brooks Rady c2f06f6cca
feat(derive): enable more boxed types to be #[diagnostic_source] (#338) 2024-02-07 10:20:18 -08:00
Kat Marchán 1fa7f5241f
fix(fmt): remove nightly-only fmt flags 2024-02-03 20:14:01 -08:00
Kat Marchán ab59a7bc9b
feat(MSRV): Actually bump the MSRV to 1.70.0 2024-02-03 19:59:57 -08:00
Kat Marchán e5c7ae469e
feat(deps): remove is-terminal dep in favor of `std::io::IsTerminal` 2024-02-03 19:50:30 -08:00
Adam Curtis e65d0a78cc
feat(highlighting): add syntax highlighting support with syntect crate (#313) 2024-02-03 19:47:46 -08:00
Gavrilikhin Daniil fad0e76ad2
feat(source): use `usize` for length (#265)
BREAKING CHANGE: This changes `SourceSpan`'s length type to `usize`.
2024-02-03 19:38:00 -08: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 a9c2bae9dc
docs: Improve linking. (#289) 2023-09-18 09:12:56 -07:00
Bennett Hardwick 2e3e5c9d15
feat(protocol): add StdError impl for Box<dyn Diagnostic + Send + Sync> (#273) 2023-06-28 18:58:35 -07:00
kleines Filmröllchen 46adb3bc6a
feat(const): Constify various functions (#263)
This is primarily aimed at making `SourceSpan` and `SourceOffset` usable
in const contexts.

Constifiable functions were found with the
`clippy::missing_const_for_fn` lint, though it reported at least two
false positives.
2023-05-17 15:42:42 -07:00
Gavrilikhin Daniil c25676cb1f
feat(serde): Add `serde` support (#264)
Fixes: https://github.com/zkat/miette/issues/260
2023-05-14 01:43:40 -07:00
Gavrilikhin Daniil 024145dbdd
Add dynamic diagnostic (#262) 2023-05-13 13:59:43 -07:00
Erich Gubler ed486c959d
feat(protocol): implement `Ord` for `Severity` (#240)
Fixes: https://github.com/zkat/miette/issues/239
2023-03-01 15:48:11 -08:00
dalance 3497508aa9
fix(graphical): Fix wrong severity of related errors (#234) 2023-02-08 16:26:27 -08:00
Andrew Hickman c3e6c98336
fix(utils): Fix off-by-one error in SourceOffset::from_location (#190) 2022-08-02 14:38:22 -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 1e1d615253 feat(spans): add From shorthand for zero-length SourceSpans 2022-04-22 18:44:09 -07:00
Rain 5e54b29acf
feat(spans): make SourceSpan implement Copy (#151)
SourceSpan is just a pair of usizes, so it's cheap to copy.
2022-04-17 15:27:11 -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
Kyle Brown 5b8b5478b6
feat(derive): Make derive macro `diagnostic` attribute more flexible. (#115)
Fixes: #114 

* Improved defaulting

* Added correct combining logic
Added variable number of diagnostic attributes

* Error handling, testing, and docs improvements

Co-authored-by: Kyle Brown <kyleb@liquidrocketry.com>
2022-02-17 22:04:03 -08:00
Coenen Benjamin 0169fe20e7
feat(SourceSpan): add impl From<Range> (#78)
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-10-01 12:02:39 -07:00
Kat Marchán 8e11baab7b feat(related): Add related diagnostics (#68)
Fixes: https://github.com/zkat/miette/issues/47
2021-09-22 16:34:21 -07:00
Kat Marchán 4bb9d12102 feat(handlers): Update graphical handler to use new label protocol (#66) 2021-09-22 16:34:21 -07:00
Kat Marchán 9aa8ff0d31 feat(protocol): Make SourceCode Send+Sync 2021-09-22 16:34:21 -07:00
Kat Marchán f87b158b22 feat(labels): replace snippet stuff with simpler labels (#62) 2021-09-22 16:34:21 -07:00
Kat Marchán c3505fac26 fix(protocol): implement source/cause for Box<dyn Diagnostic> 2021-09-22 16:34:21 -07:00
Kat Marchán 2c43740346 feat(theme): more styling changes 2021-09-22 16:34:21 -07:00
Kat Marchán 3f9da04b86
feat(report): anyhow-ify DiagnosticReport (#35)
This PR overhauls the toplevel/main experience for `miette`. It adds a new `Report` type based on `eyre::Report` and overhauls various types to fit into this model, as well as prepare for some [future changes in Rust](https://github.com/nrc/rfcs/pull/1) that will make it possible to integrate `miette` directly with crates like `eyre` instead of having to use this specific `Report`.

As such, this PR is a major breaking change, especially for anyone using `DiagnosticReport` and company.

BREAKING CHANGES:
* `DiagnosticReport` is now just `Report`, and is a different, `eyre::Report`-like type.
* `DiagnosticResult` is now just `Result`.
* `.into_diagnostic()` now just transforms the error into a `Report`.
* `DiagnosticReportPrinter` has been replaced with `ReportHandler`
* `set_printer` has been replaced by `set_hook`
* `code` is now optional.
* `.into_diagnostic()` no longer takes a `code` argument.
* `#[diagnostic]` is now optional when deriving `Diagnostic`.
2021-09-04 21:22:46 -07:00
Kat Marchán 61283e9efe
feat(snippets): Overhauled how snippets handle labels, sources, and messages, including the derive macro
BREAKING CHANGE: this will probably break a lot of your stuff. hopefully rustc helps
2021-08-22 19:06:47 -07:00
Kat Marchán 7e76e2dea4
feat(links): added URL linking support and automatic docs.rs link generation
Fixes: https://github.com/zkat/miette/issues/17
2021-08-22 15:42:08 -07:00
Kat Marchán 949174e598
misc: more aggressive linting for quality~ 2021-08-21 23:13:25 -07:00
Kat Marchán 20bb3db3fa
docs: overhaul readme and make sure everything is documented
Fixes: https://github.com/zkat/miette/issues/15
2021-08-21 22:57:16 -07:00
Kat Marchán 5c077d30a4
fix(protocol): oops, missed a spot after a rename 2021-08-21 22:54:59 -07:00
Kat Marchán d675334e48
feat(reporter): fancy new reporter with unicode, colors, and multiline (#23)
Fixes: https://github.com/zkat/miette/issues/3
Fixes: https://github.com/zkat/miette/issues/5
2021-08-20 20:09:23 -07:00
Kat Marchán 29c1403efd
feat(reporter): Overhauled return type/main/DiagnosticReport experience.
Fixes: https://github.com/zkat/miette/issues/13
2021-08-17 23:41:03 -07:00
Kat Marchán 26f409c525
feat(offsets): nice utility function to get an offset from a Rust callsite
Fixes: https://github.com/zkat/miette/issues/19
2021-08-17 19:18:57 -07:00
Kat Marchán 75c2312755
feat(offsets): utility function for converting from line/col to offset 2021-08-17 18:31:12 -07:00
Kat Marchán 95200366a1
feat(offsets): more utility From impls for SourceSpan 2021-08-17 18:30:38 -07:00
Kat Marchán 53074d3488
feat(protocol): add Source impls for Cow and Arc 2021-08-17 17:54:29 -07:00
Kat Marchán 49151bb095
fix(protocol): keep the owned spans 2021-08-17 17:15:05 -07:00
Kat Marchán f390520b45
feat(protocol): reference-based DiagnosticReport! 2021-08-17 15:30:52 -07:00
Kat Marchán acfeb9c5b0
feat(protocol): new SourceSpans with labels 2021-08-17 08:41:20 -07:00
Kat Marchán 36b86df9f5
feat(protocol): implement From<(usize, usize)> for SourceSpan 2021-08-16 23:46:32 -07:00
Kat Marchán 0e7702700d
feat(derive): added basic derive macro
This should be good for most basic use cases. More features will be added over time :)
2021-08-15 11:49:02 -07:00
Kat Marchán 02dd1f84d4
feat(protocol): Simplify protocol return values further
BREAKING CHANGE: Switched to Box instead of & for help/code return values.
2021-08-10 21:40:25 -04:00
Kat Marchán 3584dc600c
feat(protocol): improvements to snippets API 2021-08-07 22:59:20 -04:00
Kat Marchán 80e7dabbe4
feat(protocol): help is a single Display ref now. 2021-08-07 22:57:56 -04:00