miette-7.4.0/.cargo_vcs_info.json 0000644 00000000136 00000000001 0012333 0 ustar {
"git": {
"sha1": "b2011f693b1e912d28e84591b031e5af7af4904b"
},
"path_in_vcs": ""
} miette-7.4.0/.editorconfig 0000644 0000000 0000000 00000000222 10461020230 0013574 0 ustar 0000000 0000000 # top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
miette-7.4.0/.github/FUNDING.yml 0000644 0000000 0000000 00000001200 10461020230 0014271 0 ustar 0000000 0000000 # These are supported funding model platforms
github: [zkat]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
miette-7.4.0/.github/workflows/ci.yml 0000644 0000000 0000000 00000005470 10461020230 0015644 0 ustar 0000000 0000000 name: CI
on: [push, pull_request]
env:
RUSTFLAGS: -Dwarnings
jobs:
fmt_and_docs:
name: Check fmt & build docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- name: Install cargo-readme
run: cargo install cargo-readme
- name: Check doc consistency
shell: bash
run: diff -q README.md <(cargo readme)
|| { echo "::error::Update lib.rs then use cargo-readme to update README.md"; exit 1; }
- name: rustfmt
run: cargo fmt --all -- --check
- name: docs
run: cargo doc --no-deps
build_and_test:
name: Build & Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
features: [fancy, syntect-highlighter]
rust: [1.70.0, stable]
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
- features: syntect-highlighter
rust: 1.70.0
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: clippy
- name: Clippy
run: cargo clippy --all -- -D warnings
- name: Run tests
if: matrix.rust == 'stable'
run: cargo test --all --verbose --features ${{matrix.features}}
- name: Run tests
if: matrix.rust == '1.70.0'
run: cargo test --all --verbose --features ${{matrix.features}} no-format-args-capture
wasm:
name: Check Wasm build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: wasm32-unknown-unknown
- name: Check wasm target
run: cargo check --target wasm32-unknown-unknown --features fancy-no-syscall
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: miri,rust-src
- name: Run tests with miri
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
run: cargo miri test --all --verbose --features fancy
minimal_versions:
name: Minimal versions check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Run minimal version build
run: cargo build -Z direct-minimal-versions --features fancy,no-format-args-capture
miette-7.4.0/.gitignore 0000644 0000000 0000000 00000000660 10461020230 0013115 0 ustar 0000000 0000000 /target
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
/.vscode
miette-7.4.0/CHANGELOG.md 0000644 0000000 0000000 00000157257 10461020230 0012755 0 ustar 0000000 0000000 # `miette` Release Changelog
## 7.4.0 (2024-11-27)
### Features
* **graphical:** Inherit source code to causes (#401) ([465e6b6a](https://github.com/zkat/miette/commit/465e6b6ab627f8da34baa5f46441d944fb88186e))
* **report:** Implement `WrapError` for `Option` (#409) ([7fae60fd](https://github.com/zkat/miette/commit/7fae60fd8462f95cf3140c6a3b9eb06cb7953405))
## 7.3.0 (2024-11-26)
### Features
* **SourceSpan:** add impl From (#385) ([73da45b6](https://github.com/zkat/miette/commit/73da45b65c965777a00ba64aa03a247c0e5241ca))
* **Report:** add `from_err()` method to `Report` (#403) ([93d3bd11](https://github.com/zkat/miette/commit/93d3bd118a072c35aa761f0ec74317166ec08113))
* **Diagnostic:** Implement `Diagnostic` for `Infallible` (#402) ([f3fb4c1e](https://github.com/zkat/miette/commit/f3fb4c1ecd196ce389cbd71139bb7e3b35474add))
### Performance
* **handlers:** optimize string-buffer reallocations (#387) ([b8dfcda4](https://github.com/zkat/miette/commit/b8dfcda4a8c10a14116ee275250356ac991dc7be))
### Bug Fixes
* **graphical:** fix nested error wrapping (#358) ([3eabbceb](https://github.com/zkat/miette/commit/3eabbcebf113d1d620a6a3f98e8a455414ed3042))
* **docs:** updated example image (fixes #111) (#270) ([7b42b12c](https://github.com/zkat/miette/commit/7b42b12c5f6316322ce79c59bcb9e99f5d49edb8))
* **clippy:** Fix clippy lints in docs (#365) ([ea4296da](https://github.com/zkat/miette/commit/ea4296dacec3b0e4762281d9d115c1bd69ecfac3))
* **docs:** `alt` attribut for `single-line-example.png` (#372) ([b82cc81b](https://github.com/zkat/miette/commit/b82cc81b8ea32a1cf1b4598ed5832bc8e3b0e161))
* **color:** setting NO_COLOR should not print ansi codes for non-terminals (#381) ([813232ba](https://github.com/zkat/miette/commit/813232ba7957ae09e4fb9d9416d821f4fd9da66d))
* **clippy:** fix Rust v1.78.0 clippy warnings (#382) ([e1026f75](https://github.com/zkat/miette/commit/e1026f75e0a5d19bbc8e468cb3f5292074543a97))
* **perf:** mark error constructors cold (#378) ([9bbcf3c6](https://github.com/zkat/miette/commit/9bbcf3c6017fa3455a7db714879816c1cfc511fd))
* **handlers:** Disable textwrap::smawk feature (#379) ([edfdcb52](https://github.com/zkat/miette/commit/edfdcb525ee30fc54747460ada621f13f0ed1996))
* **graphical:** Format entire link instead of just name (#389) ([bf5aa374](https://github.com/zkat/miette/commit/bf5aa3742fd664be3c93160b9c28c145b1ed8bc9))
* **clippy:** fix `clippy::doc_lazy_continuation` lints (#395) ([15beec43](https://github.com/zkat/miette/commit/15beec43303180b811d4c04d1a78775feb9b0905))
* **graphical:** Handle invalid UTF-8 in source code (#393) ([d6b45585](https://github.com/zkat/miette/commit/d6b4558502e82fa74e030ccb3c8040656590d7eb))
* **features:** Use `dep:` syntax for dependencies in features. (#394) ([789a04e3](https://github.com/zkat/miette/commit/789a04e30d041179b373b4eb8b340456534a3f0e))
* **clippy:** Fix `needless_return` lint. (#405) ([5f441d01](https://github.com/zkat/miette/commit/5f441d011560a091fe5d6a6cdb05f09acf622d36))
### Documentation
* **examples:** add serde_json integration example (#407) ([2902a233](https://github.com/zkat/miette/commit/2902a2337c2e36a5d8e0e54b007d6100cca0c9ff))
## 7.2.0 (2024-03-07)
### Features
* **wasm:** add feature "fancy-no-syscall" for wasm targets (#349) ([328bf379](https://github.com/zkat/miette/commit/328bf3792213fc0bed94e72a39acb722b65141dd))
### Bug Fixes
* **label-collections:** Label collection fixes and cleanup (#343) ([75fea093](https://github.com/zkat/miette/commit/75fea0935e495d0215518c80d32dd820910982e3))
* **invalid span:** skip the snippet when read_span fails (#347) ([7d9dfc6e](https://github.com/zkat/miette/commit/7d9dfc6e8e591f9606c3da55bd8465962358b20f))
* **redundant-import:** fix a warning and CI failure in nightly (#348) ([6ea86a22](https://github.com/zkat/miette/commit/6ea86a2248854acf88df345814b6c97d31b8b4d9))
## 7.1.0 (2024-02-16)
### Features
* **derive:** enable more boxed types to be #[diagnostic_source] (#338) ([c2f06f6c](https://github.com/zkat/miette/commit/c2f06f6cca15cbdd083dbff3d46b7729056ac6a4))
* **source:** derive common traits for NamedSource, SourceSpan, and SourceOffset (#340) ([6f09250c](https://github.com/zkat/miette/commit/6f09250cca14561f07fba899a8e6d3c0df14230e))
* **collection:** add support for collection of labels (#341) ([03060245](https://github.com/zkat/miette/commit/03060245d816a53a33209e6b7e1c3c42948e9962))
### Bug Fixes
* **tests:** revert test-breaking changes of e5c7ae4 (#339) ([6e829f8c](https://github.com/zkat/miette/commit/6e829f8c0ce2fc7bb2fc4041e6a6072f12db1f71))
## 7.0.0 (2024-02-05)
This is a small breaking release on the heels of 6.0 because I neglected to
bump owo-colors. I figured it's a good time to do it, before 6.0 gets more
widely used.
### Features
* **fancy:** Add option to change the link display text (#335) ([c7144ee5](https://github.com/zkat/miette/commit/c7144ee513bf8f06c5f7d89c45436802994a51fc))
* **deps:** bump dependencies ([a4011d17](https://github.com/zkat/miette/commit/a4011d174c40acbba5b0176db7cb71ec5ca0cb49))
* **BREAKING CHANGE**: This bumps owo-colors to 4.0, which is a breaking change because we expose its styles as part of the graphical renderer API
## 6.0.1 (2024-02-04)
### Bug Fixes
* **graphical:** oops. Fix theme issue ([8b46679c](https://github.com/zkat/miette/commit/8b46679c3647e1455d91b4c68743c619fb3f3eb3))
* **fmt:** remove nightly-only fmt flags ([1fa7f524](https://github.com/zkat/miette/commit/1fa7f5241fb91d2e5bad9b0e26bcc7cd5f9011f1))
* **highlighter:** ugh, missed another spot ([ab7c066e](https://github.com/zkat/miette/commit/ab7c066e7675d8c7ecb956000d278fc31f3bc6a1))
## 6.0.0 (2024-02-04)
The long-awaited 6.0 release of `miette` is here, with TONS of goodies, not
least of which is syntax highlighting support!
It also comes with a few breaking changes so make sure to check below and
update your code as needed!
### Features
* **labels:** Add support for primary label in specifying line/col information (#291) ([db0b7e40](https://github.com/zkat/miette/commit/db0b7e403a5ae52ae360991b6508490d8c579886))
* **derive:** Allow optional sources in derive (#301) ([88d00e0e](https://github.com/zkat/miette/commit/88d00e0e20bf95e03b8f81dcd5adf38c917e190e))
* **derive:** Make `miette-derive` be able to be turned off (#304) ([c7ba5b7e](https://github.com/zkat/miette/commit/c7ba5b7e52e05991cecd3ca925c710bbe49850b9))
* **graphical:** Expose additional `textwrap` options (#321) ([fd77257c](https://github.com/zkat/miette/commit/fd77257cee0f5d03aa7dccb4ba8cbaa40c1a88c6))
* **graphical:** support rendering labels that contain newlines (#318) ([865d67c8](https://github.com/zkat/miette/commit/865d67c8dda119ddd03ac43be22f4fa272a9f433))
* **graphical:** Add `wrap_lines: bool` option allowing wrapping be disabled entirely (#328) ([b0744462](https://github.com/zkat/miette/commit/b0744462adbbfbb6d845f382db36be883c7f3c45))
* **graphical:** render disjoint snippets separately for cleaner output (#324) ([19c22143](https://github.com/zkat/miette/commit/19c22143cb544616046784e35c5e78cc5b881289))
* **deps:** Bump terminal-size to v0.3.0 (#308) ([c0a298e5](https://github.com/zkat/miette/commit/c0a298e5a8d699acf9fcd61b5d5fa4f6279a47ab))
* **BREAKING CHANGE**: This requires an MSRV bump to 1.70.0.
* **source-code:** Don't override provided source code (#300) ([0d5c2ce7](https://github.com/zkat/miette/commit/0d5c2ce7536b0ea205346595d8a00d00bfb6cbd2))
* **BREAKING CHANGE**: Source code is no longer overridden if it was provided by the diagnostic's own `source_code()` impl.
* **source:** use `usize` for length (#265) ([fad0e76a](https://github.com/zkat/miette/commit/fad0e76ad2e19d5cac13cf8324338aca0d623d93))
* **BREAKING CHANGE**: This changes `SourceSpan`'s length type to `usize`.
* **source:** Allow inner source type of a NamedSource to be borrowed (#254) ([1df3b1a5](https://github.com/zkat/miette/commit/1df3b1a537f2e54cd40ec45f5cd851337a22e95a))
* **BREAKING CHANGE**: This makes the `NamedSource` type generic over its `Source` type, instead of boxing it.
* **highlighting:** add syntax highlighting support with syntect crate (#313) ([e65d0a78](https://github.com/zkat/miette/commit/e65d0a78cc639653f061a45d8ce35b1a3551ade7))
* **deps:** remove is-terminal dep in favor of `std::io::IsTerminal` ([e5c7ae46](https://github.com/zkat/miette/commit/e5c7ae469e40a8bc102e1fca3b8fd4b2ec137696))
* **deps:** remove once_cell dep in favor of `std::sync::OnceLock` ([4c48584f](https://github.com/zkat/miette/commit/4c48584f304414c6924bede3308b455cfef60749))
* **BREAKING CHANGE**: This requires an MSRV bump to 1.70.0.
* **deps:** bump some semver-breaking deps to newer versions ([29d000f2](https://github.com/zkat/miette/commit/29d000f201b259a056867a2876384f97653a6e9e))
* **MSRV:** Actually bump the MSRV to 1.70.0 ([ab59a7bc](https://github.com/zkat/miette/commit/ab59a7bc9bceace5761a862ee2ebff3e5943b12f))
### Bug Fixes
* **misc:** Improve ci and fix clippy (#290) ([cc81382a](https://github.com/zkat/miette/commit/cc81382a6070dd226a20e4a39518d88e957ac0e1))
* **tests:** Fix `cargo test` with default features. (#294) ([1f448e47](https://github.com/zkat/miette/commit/1f448e47751d0f914134b0e9138fdb1a5a95d55c))
* **clippy:** Add missing semicolons where nothing is returned. (#293) ([06b34823](https://github.com/zkat/miette/commit/06b348230aaf153b8b050322f05e5d185351d2d1))
* **graphical:** Extend error text span to whole code points (#312) ([a8b4ae01](https://github.com/zkat/miette/commit/a8b4ae012aa0cf03b53a18f013c2b3f76c5040e7))
* **formatting:** Fix formatting bug when an empty span is not aligned to a char boundary (#314) ([3d6f903d](https://github.com/zkat/miette/commit/3d6f903df0e7c9d0eb9a1fdbbf0028bab5496429))
* **docs:** add example to README and docs fixing #96 (#319) ([251d6d59](https://github.com/zkat/miette/commit/251d6d59292397458328ef57fb7957faedafd019))
* **graphical:** rendering bug on small spans in large spans (#316) ([7ff4f874](https://github.com/zkat/miette/commit/7ff4f874d693a665af4df40f4e94505013e3e262))
* **graphical:** render cause chains for inner errors (#330) ([cb2ae2e1](https://github.com/zkat/miette/commit/cb2ae2e18b446a5e90885faf8a30b5672c307df8))
* **handler:** remove the two extra `is_terminal` sys call from `MietteHandlerOpts::build` (#325) ([f1dc89c0](https://github.com/zkat/miette/commit/f1dc89c07640445d224b61ef96c6b25fcdf62dee))
### Documentation
* **README:** Move import of `NamedResult` to where it is used (#309) ([d37ada87](https://github.com/zkat/miette/commit/d37ada876a5831d3f47622274e334c9a24aa5d2b))
## 5.10.0 (2023-07-16)
### Features
* **protocol:** add StdError impl for Box (#273) ([2e3e5c9d](https://github.com/zkat/miette/commit/2e3e5c9d15e234495369e9b47d032644dd5664ad))
## 5.9.0 (2023-05-18)
### Features
* **serde:** Add `serde` support (#264) ([c25676cb](https://github.com/zkat/miette/commit/c25676cb1f4266c2607836e6359f15b9cbd8637e))
* **const:** Constify various functions (#263) ([46adb3bc](https://github.com/zkat/miette/commit/46adb3bc6aa6518d82a4187b34c56e287922136f))
* **nested:** Render inner diagnostics (#170) ([aefe3237](https://github.com/zkat/miette/commit/aefe323780bda4e60feb44bb96ee98634ad677ad))
### Bug Fixes
* **misc:** Correct some typos (#255) ([675f3411](https://github.com/zkat/miette/commit/675f3411e33d5fae86d4018c3b72f751a4c4bc2f))
## 5.8.0 (2023-04-18)
### Features
* **source:** Add getter for NamedSource name (#252) ([be3b2547](https://github.com/zkat/miette/commit/be3b25475147e92fae631b510c8de22949eada45))
### Bug Fixes
* **narrated:** put URLs in their own line ([adbff65e](https://github.com/zkat/miette/commit/adbff65e4ed52103569a3a5cd09c1bee79f8e361))
## 5.7.0 (2023-04-01)
While this is a semver-minor release, there's potential for it to have
knock-on effects due to the syn2 upgrade. There's been issues as this new
version propagates between syn/thiserror versions (for example, see [a similar
change in eyre](https://github.com/yaahc/eyre/pull/92)).
The other thing of note is that backtrace printing is now **much** better! Try
the hook and see for yourself!
### Features
* **deps:** update to syn2 (#247) ([a2157205](https://github.com/zkat/miette/commit/a215720576fbda249138808f3469017d81eda9f0))
* **panic:** improved backtrace handling ([b0453215](https://github.com/zkat/miette/commit/b0453215f62318bedeb4af1cb00dcefbb739d619))
### Bug Fixes
* **colors:** change unicode to default to ansi (#249) ([159f2b35](https://github.com/zkat/miette/commit/159f2b354b7ea83f842a58be98c45d0175b1faad))
* **tests:** disable doctest that doesn't work with default feature flags (#248) ([0b445dc2](https://github.com/zkat/miette/commit/0b445dc2b4b30d40f03defc130bfa3e7396b51d4))
## 5.6.0 (2023-03-14)
### Bug Fixes
* **ci:** configure clippy-specific MSRV ([b658fc02](https://github.com/zkat/miette/commit/b658fc020b23b0715339c5c60f7c12c947f9a747))
* **graphical:** Fix wrong severity of related errors (#234) ([3497508a](https://github.com/zkat/miette/commit/3497508aa9b8d8503d7aae997738a4323408ffa0))
* **atty:** Switch out `atty` for `is-terminal` (#229) ([443d240f](https://github.com/zkat/miette/commit/443d240f49e9f48756ee88e4cdc377f09d44454e))
### Features
* **protocol:** implement `Ord` for `Severity` (#240) ([ed486c95](https://github.com/zkat/miette/commit/ed486c959d8e8fbd4247af7d47d7e32c8a88321d))
## 5.5.0 (2022-11-24)
### Features
* **SourceCode:** Implement SourceCode for Vec (#216) ([c857595e](https://github.com/zkat/miette/commit/c857595e1ae689028c5c5b66148e81b175eaa509))
### Bug Fixes
* **derive:** elide lifetimes in derived functions (#226) ([c88f0b5a](https://github.com/zkat/miette/commit/c88f0b5aa0786a0f4bb778686548f91db96ea6af))
* **graphical:** Fix panic with span extending past end of line (#221) ([8b56d277](https://github.com/zkat/miette/commit/8b56d277ef476438a1c7383c29f6c1a0a1684818))
* **license:** fix mangled license text to improve recognition ([d5fbb340](https://github.com/zkat/miette/commit/d5fbb3409c7cc950c502eb77578d5f1062384fb5))
## 5.4.1 (2022-10-28)
### Bug Fixes
* **graphical:** Fix panic with zero-width span at end of line (#204) ([b8810ee3](https://github.com/zkat/miette/commit/b8810ee3d8aee7d7723e081616dd4f2fe8748abe))
## 5.4.0 (2022-10-25)
### Features
* **version:** declare minimum supported rust version at 1.56.0 (#209) ([ac02a124](https://github.com/zkat/miette/commit/ac02a1242b1d6452a428846d2a84d2ac164fd914))
* **report:** `Report::new_boxed` ([0660d2f4](https://github.com/zkat/miette/commit/0660d2f43c0a793b1e289b26bcca73c8733bdcff))
* **error:** `impl AsRef for Report` ([1a27033d](https://github.com/zkat/miette/commit/1a27033d7afd0007907550b1fc9d589d6f658662))
### Bug Fixes
* **wrapper:** complete forwarding `Diagnostic` implementations ([3fc5c04c](https://github.com/zkat/miette/commit/3fc5c04cbbd4b92863290a488a23d5243c16fe60))
## 5.3.1 (2022-09-10)
### Bug Fixes
* **miri:** Resolve Miri's concerns around unsafe code (#197) ([5f3429b0](https://github.com/zkat/miette/commit/5f3429b0626034328a0c2f1317b8a0e712c63775))
* **graphical:** Align highlights correctly with wide unicode characters and tabs (#202) ([196c09ce](https://github.com/zkat/miette/commit/196c09ce7af9e54b63aaa5dae4cd199f2ecba3fa))
## 5.3.0 (2022-08-10)
### Bug Fixes
* **utils:** Fix off-by-one error in SourceOffset::from_location (#190) ([c3e6c983](https://github.com/zkat/miette/commit/c3e6c983363af7f7a88e52d50d57404defb1bf49))
### Features
* **graphical:** Allow miette users to opt-out of the rendering of the cause chain (#192) ([b9ea5871](https://github.com/zkat/miette/commit/b9ea587159464c0090d9510567e5ea93bb772b49))
## 5.2.0 (2022-07-31)
### Features
* **json:** `causes` support (#188) ([c95f58c8](https://github.com/zkat/miette/commit/c95f58c87a1335e956be23879754ac312a2b0853))
### Bug Fixes
* **docs:** readme was getting cut off during generation ([e286c705](https://github.com/zkat/miette/commit/e286c705fda28c02df67a584c0a013a1bbc38968))
## 5.1.1 (2022-07-09)
### Bug Fixes
* **deps:** bump minimum supports-color version (#182) ([ccf1b8ad](https://github.com/zkat/miette/commit/ccf1b8ade5b631e05fad79d1f9c5d268706d118e))
* **graphical:** handle an empty source (#183) ([12dc4007](https://github.com/zkat/miette/commit/12dc40070a99ac91b67e23f7c15ce8151965fc81))
## 5.1.0 (2022-06-25)
### Features
* **protocol:** Implement SourceCode for Arc (and similar types) (#181) ([85da6a84](https://github.com/zkat/miette/commit/85da6a8407ef727b8f77184b8a61f5b9a7d3ccef))
## 5.0.0 (2022-06-24)
### Breaking Changes
* **theme:** restructure automatic color selection (#177) ([1816b06a](https://github.com/zkat/miette/commit/1816b06a2efcd5705dfe91147ab5651fe0b517d6))
* The default theme now prefers ANSI colors, even if RGB is supported
* `MietteHandlerOpts::ansi_colors` is removed
* `MietteHandlerOpts::rgb_color` now takes an enum that controls the color
format used when color support is enabled, and has no effect otherwise.
### Bug Fixes
* **json:** Don't escape single-quotes, that's not valid json (#180) ([b193d3c0](https://github.com/zkat/miette/commit/b193d3c002be8a42fd199911cef3465e2e0cb593))
## 4.7.1 (2022-05-13)
### Bug Fixes
* **tests:** add Display impl to diagnostic_source example ([0a4cf4ad](https://github.com/zkat/miette/commit/0a4cf4ad24eb668d6668400b9ab3e8c896b33e3a))
## 4.7.0 (2022-05-05)
### Features
* **diagnostic_source:** add protocol method for Diagnostic-aware source chaining (#165) ([bc449c84](https://github.com/zkat/miette/commit/bc449c842662909d93d3a6b7e117fdbde77544e7))
### Documentation
* **IntoDiagnostic:** Warn of potential data loss (#161) ([2451ad6a](https://github.com/zkat/miette/commit/2451ad6a963c222831977e89542a7349b66f11cf))
## 4.6.0 (2022-04-23)
### Features
* **spans:** add From shorthand for zero-length SourceSpans ([1e1d6152](https://github.com/zkat/miette/commit/1e1d61525381a6699deba103a3829874676eee9c))
* **related:** print related prefixes according to severity (#158) ([084ed138](https://github.com/zkat/miette/commit/084ed138b7598d549f38fe873a758d0ed03ef2b1))
### Bug Fixes
* **graphical:** fix issue with duplicate labels when span len is 0 (#159) ([1a36fa7e](https://github.com/zkat/miette/commit/1a36fa7ec80de77e910e04cdb902270970611b39))
## 4.5.0 (2022-04-18)
### Features
* **spans:** make SourceSpan implement Copy (#151) ([5e54b29a](https://github.com/zkat/miette/commit/5e54b29acf87eacf0a0255a9d3db8966de697fcf))
* **help:** update macro to allow optional help text (#152) ([45093c2f](https://github.com/zkat/miette/commit/45093c2f587a281a37e80141d126d87944ca75b5))
* **labels:** allow optional labels in derive macro (#153) ([23ee3642](https://github.com/zkat/miette/commit/23ee3642d198ff4f78af9729d7a5223b0c676d1f))
* **help:** allow non-option values in #[help] fields ([ea55f458](https://github.com/zkat/miette/commit/ea55f458fa8acabc1c7e001c405f90025d6dbafc))
* **label:** use macro magic instead of optional flag for optional labels ([9da62cd0](https://github.com/zkat/miette/commit/9da62cd05d777f8bd962f1fe94a75c47b11ee07e))
### Bug Fixes
* **theme:** set correct field in MietteHandlerOpts::ansi_colors (#150) ([97197601](https://github.com/zkat/miette/commit/97197601ee8f36fedb559c9c8b2d73ce5b0ca0ee))
## 4.4.0 (2022-04-04)
### Features
* **report:** Add conversion from Report to Box (#149) ([b4a9d4cd](https://github.com/zkat/miette/commit/b4a9d4cd9bc43720613b7d2bb6b521d51922c6b8))
### Bug Fixes
* **docsrs:** use proper module names for docsrs URLs ([a0b972f8](https://github.com/zkat/miette/commit/a0b972f8765040fdbb08fdbe006ceb4dbc9c31f2))
* **clippy:** misc clippy fixes ([b98b0982](https://github.com/zkat/miette/commit/b98b09828215ffc623aa17aa0bc8a6f45173a3f0))
* **fmt:** cargo fmt ([37cda4a3](https://github.com/zkat/miette/commit/37cda4a3a456060050e42a199a68ab86ee679f79))
## 4.3.0 (2022-03-27)
### Features
* **reporter:** Allow GraphicalReportHandler to disable url display (#137) ([b6a6cc9e](https://github.com/zkat/miette/commit/b6a6cc9e75198e53f1413c88694d950006833e05))
### Bug Fixes
* **colors:** handler_opts.color(false) should disable color (#133) ([209275d4](https://github.com/zkat/miette/commit/209275d4377fcaf397bde931f2972a1b7d8ce55c))
* **handler:** Apply MietteHandlerOpts::graphical_theme (#138) ([70e84f9a](https://github.com/zkat/miette/commit/70e84f9a019008a38ed22416f1fc399d32f50db4))
### Documentation
* **readme:** Fix a couple links (#141) ([126ffc58](https://github.com/zkat/miette/commit/126ffc5834683726fc8efff6604735f8cc806f9b))
### Miscellaneous Tasks
* **deps:** Update textwrap to 0.15.0 (#143) ([2d0054b3](https://github.com/zkat/miette/commit/2d0054b3c9bf1f6bdbea624ba65593ca41f03999))
## 4.2.1 (2022-02-25)
### Bug Fixes
* **handlers:** source code propagation for JSON handler (#122) ([50bcec90](https://github.com/zkat/miette/commit/50bcec909aa60c20d4981484195130fbb9f3cacb))
* **clippy:** 1.59.0 clippy fix ([fa5b5fee](https://github.com/zkat/miette/commit/fa5b5fee549e53e9cf0c1d946bef242eebee6c48))
* **docs:** Docs overhaul (#124) ([5d23c0d6](https://github.com/zkat/miette/commit/5d23c0d61d0c7e778579d4d290b1f6e2c53fba31))
## 4.2.0 (2022-02-22)
### Features
* **derive:** allow `Report` in `related` (#121) ([75d4505e](https://github.com/zkat/miette/commit/75d4505e7d55e816cac071eb126213b72bf48982))
## 4.1.0 (2022-02-20)
`.with_source_code()` is here!!
### Features
* **report:** add `with_source_code` ([50519264](https://github.com/zkat/miette/commit/50519264d47d35ecbbe4846cf7d64139854adf6c))
* **handlers:** propagate source code to related errors ([3a17fcea](https://github.com/zkat/miette/commit/3a17fceabb0641c3d44f73a62b8116cc87d3c6bb))
### Bug Fixes
* **derive:** absolute path references to Diagnostic (#118) ([6eb3d2d8](https://github.com/zkat/miette/commit/6eb3d2d8a63bc38a53a472932a476b78c4fdb34c))
## 4.0.1 (2022-02-18)
### Bug Fixes
* **graphical:** boolean was messing up graphical display ([5c085b39](https://github.com/zkat/miette/commit/5c085b39e28ad87777135bcca30d2ac99039de39))
## 4.0.0 (2022-02-18)
### Breaking Changes
* **colors:** treat no-color mode as no-color instead of narratable (#94) ([9dcce5f1](https://github.com/zkat/miette/commit/9dcce5f1bdd76e7564d604ab8b87bbc7caad310a))
* **BREAKING CHANGE**: NO_COLOR no longer triggers the narrated handler. Use
NO_GRAPHICS instead.
* **derive:** Make derive macro `diagnostic` attribute more flexible. (#115) ([5b8b5478](https://github.com/zkat/miette/commit/5b8b5478b63e91a51fadec87c6fed3e60d192b60))
* **BREAKING CHANGE**: `diagnostic` attribute duplication will now error.
### Features
* **Report:** adds `.context()` method to the `Report` (#109) ([2649fd27](https://github.com/zkat/miette/commit/2649fd27c47893dc3ba2445a9932600d1b3d3e63))
### Bug Fixes
* **handlers:** Fix label position (#107) ([f158f4e3](https://github.com/zkat/miette/commit/f158f4e370bd25d589136a69058a6dff5e8aa468))
## 3.3.0 (2022-01-08)
### Features
* **deps:** Bump owo-colors to 3.0.0 ([fe77d8c7](https://github.com/zkat/miette/commit/fe77d8c75478e9915a61613ec94b3de0a70e5e26))
* **handlers:** Add JSON handler (#90) ([53b24682](https://github.com/zkat/miette/commit/53b246829a2cf6317fe1ac0cf7603e37ffde349f))
### Bug Fixes
* **chain:** correct `Chain` structure exported (#102) ([52e5ec80](https://github.com/zkat/miette/commit/52e5ec806457c2784d85dc4e4a332c07e6eea818))
* **json:** proper escapes for JSON strings (#101) ([645ef6a1](https://github.com/zkat/miette/commit/645ef6a1b66a9a05f97883535f162cab4d0483f5))
* **deps:** switch to terminal_size ([51146535](https://github.com/zkat/miette/commit/51146535f5ea9eeaff1163d99d8b89a2567e93dd))
## 3.2.0 (2021-10-06)
### Features
* **tabs:** Add replace tabs with spaces option (#82) ([1f70140c](https://github.com/zkat/miette/commit/1f70140c2e6a57237de78dab022e29440f98ae33))
### Bug Fixes
* **read_span** prevent multiline MietteSpanContents from skipping lines (#81) ([cb5a919d](https://github.com/zkat/miette/commit/cb5a919deb87f8fba748bed73b6f22ebe4e3390f))
## 3.1.0 (2021-10-01)
### Features
* **SourceSpan:** add impl From (#78) ([0169fe20](https://github.com/zkat/miette/commit/0169fe20e7868cfee594b26b063267d17be0a84e))
## 3.0.1 (2021-09-26)
No code changes this release. Just improved documentation and related tests.
## 3.0.0 (2021-09-22)
It's here! Have fun!
It's a pretty significant change, so if you were using `miette`'s snippet
support previously, you'll need to update your code.
### Bug Fixes
* **report:** miscellaneous, hacky tweaks to graphical rendering ([80036781](https://github.com/zkat/miette/commit/80036781cda11de071187d59127c6d1c7cafa879))
* **protocol:** implement source/cause for Box ([c3505fac](https://github.com/zkat/miette/commit/c3505fac269aebadc0fd62f9ee4e04bd00970dae))
* **derive:** Code is no longer required ([92a31509](https://github.com/zkat/miette/commit/92a3150921d366e2850249be14259a550fcee3bb))
* **graphical:** stop rendering red vbars before the last item ([e2e4027f](https://github.com/zkat/miette/commit/e2e4027fda55415ac07590e2d33e1f6d762df439))
* **graphical:** fix coalescing adjacent things when they cross boundaries ([18e0ed77](https://github.com/zkat/miette/commit/18e0ed7749d33c5030a5fa2f8eabdc50a717573b))
* **context:** get labels/snippets working when using .context() ([41cb710a](https://github.com/zkat/miette/commit/41cb710a7dff59a9bde126556be7f5a877c1dafd))
* **api:** put panic handler properly behind a flag ([55ca8e0b](https://github.com/zkat/miette/commit/55ca8e0b7ff60cef8a7f75c29fa78edbb8114043))
* **deps:** We do not use ci_info directly anymore ([8d1170e2](https://github.com/zkat/miette/commit/8d1170e2decee290f1679b823eb0f7ea04f3fb39))
* **graphical:** Fix off-by-one span_applies calculation (#70) ([a6902042](https://github.com/zkat/miette/commit/a69020422e546efbe9256e30d9da10ad67f5ce03))
* **theme:** remove code styling ([ce0dea54](https://github.com/zkat/miette/commit/ce0dea541a60f274bd97d3a1cfdaa9d217b632e2))
* **graphical:** render URLs even without a code ([77c5899b](https://github.com/zkat/miette/commit/77c5899bbd7c46733ea208a7506c1d07b773bc2c))
* **deps:** remove dep on itertools ([612967d3](https://github.com/zkat/miette/commit/612967d381f05e2e5a27e39a7a66942c7ec396f3))
### Features
* **report:** make a single big MietteHandler that can switch modes ([4c2463f9](https://github.com/zkat/miette/commit/4c2463f9aeaef43f69cac3abae059973f430bfa8))
* **BREAKING CHANGE**: linkification option method on GraphicalReportHandler has been changed to .with_links(bool)
* **deps:** move fancy reporter (and its deps) to a feature ([247e8f8b](https://github.com/zkat/miette/commit/247e8f8b39271ffa7fd2c461e8ed769bebcbc589))
* **BREAKING CHANGE**: The default fancy reporter is no longer available unless you enable the "fancy" feature. This also means you will not be pulling in a bunch of deps if you are using miette for a library
* **footer:** add footer support to graphical and narrated ([93374173](https://github.com/zkat/miette/commit/93374173e30c5d4ccdd0aa16557d68d54aaf3e59))
* **theme:** rename some theme items for clarity ([c5c0576e](https://github.com/zkat/miette/commit/c5c0576ec69d5ccc3700dd6fc411d071bb0114a7))
* **BREAKING CHANGE**: These were part of the public API, so if you were using theming, this might have broken for you
* **theme:** more styling changes ([2c437403](https://github.com/zkat/miette/commit/2c43740346da954fd71653a079c53a1e9612c06f))
* **report:** add debug report as default, instead of narrated one ([9841d6fd](https://github.com/zkat/miette/commit/9841d6fd77ce665acb40f7459f410e83cdc131c0))
* **labels:** replace snippet stuff with simpler labels (#62) ([f87b158b](https://github.com/zkat/miette/commit/f87b158b22f6f943cd7e52ca186b5f3c542194fd))
* **protocol:** Make SourceCode Send+Sync ([9aa8ff0d](https://github.com/zkat/miette/commit/9aa8ff0d3190e0fb1ee5ad48cb540b961fc46366))
* **handlers:** Update graphical handler to use new label protocol (#66) ([4bb9d121](https://github.com/zkat/miette/commit/4bb9d12102c1e24b6f063e43bd87e894f16683e8))
* **report:** nicer, non-overlapping same-line highlights ([1a0f359e](https://github.com/zkat/miette/commit/1a0f359e3cd386f2738052d68790a3b54e64055b))
* **panic:** Add basic panic handler and installation function ([c6daee7b](https://github.com/zkat/miette/commit/c6daee7b930ff7b76ce6ab394460c7659124f2d6))
* **panic:** add backtrace support to panic handler and move set_panic_hook into fancy features ([858ac169](https://github.com/zkat/miette/commit/858ac169353e653ed0795fb1962f4ddde8fc3d06))
* **graphical:** simplify graphical header and remove a dep ([6c648463](https://github.com/zkat/miette/commit/6c6484633ed1580047fb3dc820486f3264fb6a19))
* **related:** Add related diagnostics (#68) ([8e11baab](https://github.com/zkat/miette/commit/8e11baab7b7b57d6220cf31a82715ac9b8b76f2f))
* **graphical:** compact graphical display a bit ([db637a36](https://github.com/zkat/miette/commit/db637a366b1bcf54ff761a43ddb2cdfaaac0e481))
* **graphical:** compact even more ([72c0bb9e](https://github.com/zkat/miette/commit/72c0bb9e65fa2fc7e8a1cf61ab1fe636ec063d2e))
* **graphical:** add theming customization for linums ([717f8e3d](https://github.com/zkat/miette/commit/717f8e3d8837e14d76825603c0cbdcabb66950ff))
* **handler:** context lines config support ([b33084bd](https://github.com/zkat/miette/commit/b33084bdbfeec90208f9dacd1976c8bde31642f3))
* **narrated:** updated narrated handler ([fbf6664e](https://github.com/zkat/miette/commit/fbf6664ef5582c9a15bba881a6ee1ca058102d7f))
* **narrated:** global footer and related diagnostics support ([3213fa61](https://github.com/zkat/miette/commit/3213fa610a17e3f52ece8c069eb123b2a38f1266))
## 3.0.0-beta.0 (2021-09-22)
Time to get ready for release!
### Bug Fixes
* **graphical:** stop rendering red vbars before the last item ([dc2635e1](https://github.com/zkat/miette/commit/dc2635e15154ab33506bdeae46f34c99b403fff2))
* **graphical:** fix coalescing adjacent things when they cross boundaries ([491ce7c0](https://github.com/zkat/miette/commit/491ce7c0ce1f04c9b6fc09c250f188c1ec77df53))
* **context:** get labels/snippets working when using .context() ([e0296578](https://github.com/zkat/miette/commit/e02965787b5e6206dad46556a50edae578449789))
### Features
* **report:** nicer, non-overlapping same-line highlights ([338c885a](https://github.com/zkat/miette/commit/338c885a305035fc21f63e3566131af5befa14b3))
* **panic:** Add basic panic handler and installation function ([11a708a2](https://github.com/zkat/miette/commit/11a708a2244f1838351b2b59bfc407febe3c2a0e))
* **panic:** add backtrace support to panic handler and move set_panic_hook into fancy features ([183ecb9b](https://github.com/zkat/miette/commit/183ecb9b78a1c22d832e979db5054dcac36d8b7a))
* **graphical:** simplify graphical header and remove a dep ([9f36a4c2](https://github.com/zkat/miette/commit/9f36a4c25362486dfcf9ad2bd66c45e47d6fa4d2))
* **related:** Add related diagnostics (#68) ([25e434a2](https://github.com/zkat/miette/commit/25e434a2cec93e41f020372dedcf395adb2564de))
* **graphical:** compact graphical display a bit ([9d07dc5a](https://github.com/zkat/miette/commit/9d07dc5a1c190b6d52770e4f3c4a1dabd53e0fd5))
* **graphical:** compact even more ([712e75fd](https://github.com/zkat/miette/commit/712e75fd8c25c6309a49c7f81f83d5b6f855594c))
## 3.0.0-alpha.0 (2021-09-20)
This is the first WIP alpha release of miette 3.0!
It's a MAJOR rewrite of the entire snippet definition and rendering system,
and you can expect even more changes before 3.0 goes live.
In the meantime, there's this. :)
### Bug Fixes
* **report:** miscellaneous, hacky tweaks to graphical rendering ([8029f9c6](https://github.com/zkat/miette/commit/8029f9c6c39d9d9592a2183380e83add8f9938e1))
* **protocol:** implement source/cause for Box ([3e8a27e2](https://github.com/zkat/miette/commit/3e8a27e263d6b22c1f2a9b192b2d305c2f0aa367))
* **derive:** Code is no longer required ([8a0f71e6](https://github.com/zkat/miette/commit/8a0f71e6d11cd6f89fbad67cce46e34aa75f3b39))
### Features
* **report:** make a single big MietteHandler that can switch modes ([3d74a500](https://github.com/zkat/miette/commit/3d74a500c3193fb1dff26591191a67eaab079671))
* **BREAKING CHANGE**: linkification option method on GraphicalReportHandler has been changed to .with_links(bool)
* **deps:** move fancy reporter (and its deps) to a feature ([bc495e6e](https://github.com/zkat/miette/commit/bc495e6ed49f227895260d8877685e267c0d5814))
* **BREAKING CHANGE**: The default fancy reporter is no longer available unless you enable the "fancy" feature. This also means you will not be pulling in a bunch of deps if you are using miette for a library
* **footer:** add footer support to graphical and narrated ([412436cd](https://github.com/zkat/miette/commit/412436cd689ac55e9ec8172f772c321288629553))
* **theme:** rename some theme items for clarity ([12a9235b](https://github.com/zkat/miette/commit/12a9235bec53d6dbd347f43dfaef167696a381e1))
* **BREAKING CHANGE**: These were part of the public API, so if you were using theming, this might have broken for you
* **theme:** more styling changes ([9901030e](https://github.com/zkat/miette/commit/9901030eb160e72bc64144c44b8bf48cce8dfe48))
* **report:** add debug report as default, instead of narrated one ([eb1b7222](https://github.com/zkat/miette/commit/eb1b7222fc5b73b6fb8fee90b1de27e0b8d6d588))
* **labels:** replace snippet stuff with simpler labels (#62) ([0ef2853f](https://github.com/zkat/miette/commit/0ef2853f27ea84407789cbd0680956f9e3ee9168))
* **protocol:** Make SourceCode Send+Sync ([eb485658](https://github.com/zkat/miette/commit/eb485658cc5a0df894c59d6ad29f945fff2839a5))
* **handlers:** Update graphical handler to use new label protocol (#66) ([6cd44a86](https://github.com/zkat/miette/commit/6cd44a86c6e6f1d9c79006d4cfa89220dbd3a7b4))
## 2.2.0 (2021-09-14)
So it turns out [`3.0.0` is already under way](https://github.com/zkat/miette/issues/45), if you didn't already hear!
It's going to be an exciting release, but we'll still be putting out bugfixes
and (backwards-compatible) features in the `2.x` line until that's ready.
And there's definitely stuff in this one to be excited about! Not least of all
the ability to _forward_ diagnostic metadata when wrapping other
`Diagnostic`s. Huge thanks to [@cormacrelf](https://github.com/cormacrelf) for
that one!
We've also got some nice improvements to reporter formatting that should make
output look at least a little nicer--most notably, we now wrap messages and
footers along the appropriate column so formatting keeps looking good even
when you use newlines!
Finally, huge thanks to [@icewind1991](https://github.com/icewind1991) for
fixing a [really weird-looking bug](https://github.com/zkat/miette/pull/52)
caused by an off-by-one error. Oopsies 😅
### Features
* **report:** wrap multiline messages to keep formatting ([f482dcec](https://github.com/zkat/miette/commit/f482dcec6a4e981c256854f73506ed01abaa65f9))
* **report:** take terminal width into account for wrapping text ([bc725324](https://github.com/zkat/miette/commit/bc72532465bde00e11d83ff4a9f767051ee6771d))
* **report:** make header line as wide as terminal ([eaebde92](https://github.com/zkat/miette/commit/eaebde92cf528d50d799dd60acd98b16978e8681))
* **derive:** Add `#[diagnostic(forward(field_name), code(...))]` (#41) ([2fa5551c](https://github.com/zkat/miette/commit/2fa5551c81831734fd9a162463a4a939dff9dfba))
### Bug Fixes
* **report:** get rid of the weird arrow thing. it does not look good ([1ba3f2f5](https://github.com/zkat/miette/commit/1ba3f2f5d292419571302477195836f89d9c7cb5))
* **report:** fix wrapping for header and add wrapping for footer ([eb07d5bd](https://github.com/zkat/miette/commit/eb07d5bd66928457b4f3affe96aa6a0d39f642f7))
* **report:** Fix end of previous line wrongly being included in highlight (#52) ([d994add9](https://github.com/zkat/miette/commit/d994add912700873de3ebdb8d14d81516955c901))
## 2.1.2 (2021-09-10)
So it turns out I forgot to make snippets and other stuff forward through when
you use `.context()` &co. This should be fixed now 😅
### Bug Fixes
* **context:** pass on diagnostic metadata when wrapping with `Report` ([e4fdac38](https://github.com/zkat/miette/commit/e4fdac38ea8c295468ed0fce563a2df29241986a))
## 2.1.1 (2021-09-09)
This is a small, but visually-noticeable bug fix. I spent some time playing
with colors and styling and made some fixes that will improve where people's
eyes are drawn to, and also take into account color visibility issues a bit
more.
### Bug Fixes
* **report:** don't color error message text to draw eyes back to it ([6422f821](https://github.com/zkat/miette/commit/6422f8217495aeef38af4eb00feeb73ced36f7bf))
* **reporter:** improve color situation and style things a little nicer ([533ff5f3](https://github.com/zkat/miette/commit/533ff5f348324132044bd2782a17fd6c81c08259))
## 2.1.0 (2021-09-08)
This is a small release with a handful of quality of life improvements (and a small bugfix).
### Features
* **printer:** use uparrow for empty highlights and fix 0-offset display bug ([824cd8be](https://github.com/zkat/miette/commit/824cd8bebea2ae43a29d9d744d0386d00cc943e0))
* **derive:** make #[diagnostic] optional for enums, too ([ffe1b558](https://github.com/zkat/miette/commit/ffe1b558d0d7284e39fcb38c4f410cddb4cdb4bd))
## 2.0.0 (2021-09-05)
This release 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`.
On top of that, it includes a couple of nice new features, such as
`#[diagnostic(transparent)]`, which should be super useful when wrapping other
diagnostics with your own types!
### Breaking Changes
* **report:** anyhow-ify DiagnosticReport (#35) ([3f9da04b](https://github.com/zkat/miette/commit/3f9da04b866f3fd90f88e7e60f9fb7a322aef568))
* `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`.
### Features
* **derive:** Add `#[diagnostic(transparent,forward)]` (#36) ([53f5d6d1](https://github.com/zkat/miette/commit/53f5d6d1d62845b52e590fed5ce91a643b6e11f3))
* **Source:** impl Source for str, &str (make &'static str usable for testing) (#40) ([50c7a883](https://github.com/zkat/miette/commit/50c7a88360dc7cef815af2dbb9dc18ede0d1fdb4))
* **source:** Remove bound `T: Clone` from `Source` implementation for `Cow`. (#42) ([0427c9f9](https://github.com/zkat/miette/commit/0427c9f9666222084cb4494aabbd3e7dc5cdb789))
### Bug Fixes
* **reporter:** Only inc the line count if we haven't already done so with '\n' or '\r\n' (#37) ([5a474370](https://github.com/zkat/miette/commit/5a474370ddda92a3a92b6b84cd561ecaf4d6d858))
* **printer:** Show snippet message for unnamed sources (#39) ([84219f6c](https://github.com/zkat/miette/commit/84219f6c80c2c432fbeb4c40a591380285de8767))
## 1.1.0 (2021-08-29)
This is a small release of patches entirely not my own!
The exciting new feature is the ability to do `thiserror`-style
`#[diagnostic(transparent)]` when using the derive macro, which will defer
diagnostics to a Diagnostic referred to by the struct/enum!
Big thanks to [@cormacrelf](https://github.com/cormacrelf) and
[@felipesere](https://github.com/felipesere) for your contributions!
### Features
* **derive:** Add `#[diagnostic(transparent,forward)]` (#36) ([53f5d6d1](https://github.com/zkat/miette/commit/53f5d6d1d62845b52e590fed5ce91a643b6e11f3))
### Bug Fixes
* **reporter:** Only inc the line count if we haven't already done so with '\n' or '\r\n' (#37) ([5a474370](https://github.com/zkat/miette/commit/5a474370ddda92a3a92b6b84cd561ecaf4d6d858))
## 1.0.1 (2021-08-23)
This is a (literally) small release. I noticed that the crate's size had
increased significantly before I realized cargo was including the `images/`
folder. This is not needed, as these images are just hosted on GitHub.
`miette` should be smaller now, I hope :)
#### Bug Fixes
* **crate:** reduce crate size by removing images ([5f74da67](https://github.com/zkat/miette/commit/5f74da671f2444efc4840c11492773a46cecf7e9))
## 1.0.0 (2021-08-23)
...you know what? I'm just gonna tag 1.0.0, because I don't want sub-1.0
versions anymore, but the Cargo ecosystem buries pre-releases pretty
thoroughly. Integers are cheap!
So here we are! We made it to 1.0, and with some _really_ nice goodies to boot.
Most fun is the fact that the default printer now has *clickabble url linking*
support. A new `Diagnostic::url()` method has been added to the protocol that,
is used to figure out what URL to send folks to! This should work on most
"modern" terminals, but more thorough support checking will be done in the
future. And of course, the narrated reporter prints them out too.
I also took the time to completely redo how messages, labels, and filenames
are handled in the system, and this is a pretty big change you might run into.
Godspeed!
Last but not least, we got our first external contribution! Thank you to
[@martica](https://github.com/martica) for the bug fix!
Anyway, here's to 1.0, and to many more after that. Enjoy! :)
#### Breaking Changes
* **snippets:** Overhauled how snippets handle labels, sources, and messages, including the derive macro ([61283e9e](https://github.com/zkat/miette/commit/61283e9efe2825425c41027b3dbb5f4f9c9d83fb)
#### Features
* **links:** added URL linking support and automatic docs.rs link generation ([7e76e2de](https://github.com/zkat/miette/commit/7e76e2dea4adf0e4a1349e049495c1f5a0bdab87))
* **theme:** Add an initial `rgb` style with nicer colors ([3546dcec](https://github.com/zkat/miette/commit/3546dcec988ea40cc6aa8dd94c29432830cef662)) - [@martica](https://github.com/martica)
#### Bug Fixes
* **printer:** clamp highlight length to at least 1 (#32) ([9d601599](https://github.com/zkat/miette/commit/9d6015996bf3010b573b9bb5d0e48cb85f290460))
## 1.0.0-beta.1 (2021-08-22)
It's happening, folks! `miette` is now working towards stability and is now in
beta! We'll keep it like this for a little while until a few more people have
tried it out and given feedback. New features may still be added, and breaking
changes may still happen, but `miette` is now considered "good enough to use",
and breaking changes are expected to be more rare.
Oh, and as part of this release, the docs were overhauled, particularly the
README, so you might want to take a gander at them!
#### Breaking Changes
* **printer:** rename default printer and consistify some naming conventions with printing ([aafa4a3d](https://github.com/zkat/miette/commit/aafa4a3de1298dd8e7625138d09a408ff3579d3f), breaks [#](https://github.com/zkat/miette/issues/))
* **into_diagnostic:** .into_diagnostic() is now generic across any impl fmt::Display instead of expecting a `dyn` ([c1da4a0d](https://github.com/zkat/miette/commit/c1da4a0d2744e94e409cabeafe911e99598d4ee3))
#### Features
* **error:** diagnostic-ify MietteError ([e980b723](https://github.com/zkat/miette/commit/e980b7237334b56f7b8c092956d35cd2bbadac41))
#### Bug Fixes
* **derive:** #[diagnosic(severity)] works for named and unnamed variants/structs now ([adf0bc93](https://github.com/zkat/miette/commit/adf0bc933f62852514067ade96e07362c889f012))
* **protocol:** oops, missed a spot after a rename ([5c077d30](https://github.com/zkat/miette/commit/5c077d30a4aca71f71e61b2561081575c04a4d64))
## 0.13.0 (2021-08-21)
This release includes some accessibility improvements: miette now includes a "narratable" printer that formats diagnostics like this:
```
Error: Received some bad JSON from the source. Unable to parse.
Caused by: missing field `foo` at line 1 column 1700
Begin snippet for https://api.nuget.org/v3/registration5-gz-semver2/json.net/index.json starting
at line 1, column 1659
snippet line 1: gs":["json"],"title":"","version":"1.0.0"},"packageContent":"https://api.nuget.o
highlight starting at line 1, column 1699: last parsing location
diagnostic help: This is a bug. It might be in ruget, or it might be in the source you're using,
but it's definitely a bug and should be reported.
diagnostic error code: ruget::api::bad_json
```
This style is the default in a number of situations:
1. The `NO_COLOR` env var is present and set, and not `0`.
2. The `CLICOLOR` env var is present and not set to `1`.
3. `stdout` or `stderr` are not TTYs.
4. A CI environment is detected.
You can override and customize this behavior any way you want by using the
`miette::set_reporter()` function at the toplevel of your application, but we
encourage you to at least make the narratable printer an option for your
users, since miette's default printer is exceptionally bad for screen
readers.
Our hope is that this release is only the starting point towards making
miette's error reporting not just really fancy and cool, but friendly and
accessible to everyone.
#### Features
* **printer:** added (and hooked up) an accessible report printer ([5369a942](https://github.com/zkat/miette/commit/5369a9424e7ed2c66b193b85422fe8b98bc37b6c))
## 0.12.0 (2021-08-21)
This is a SUPER EXCITING release! With this, miette now has a full-featured
pretty-printer that can handle cause chains, snippets, help text, and lots
more!
Check out [the serde_json
example](https://github.com/zkat/miette/blob/5fd2765bf05edf25251ce199994b8815524fd47d/images/serde_json.png)
to see a "real-world" case!
This release also adds support for full `thiserror`-style format strings to
the `help()` diagnostic derive attribute!
We're rapidly approaching a 1.0-beta release. One more extra-fun treat left
and we can start stabilizing!
#### Features
* **derive:** format string support for help() ([8fbad1b1](https://github.com/zkat/miette/commit/8fbad1b1cd173ce3c0b803f8b2db013e278c63a6))
* **printer:** lots of small improvements to printer ([5fbcd530](https://github.com/zkat/miette/commit/5fbcd53026c131ceafe2a66bebbc20de570363c9))
* **reporter:** fancy new reporter with unicode, colors, and multiline (#23) ([d675334e](https://github.com/zkat/miette/commit/d675334e48ddc188a34e166ad040eaceda117d0a))
## 0.11.0 (2021-08-18)
BIG changes this time. The whole end-to-end experience for tossing around
Diagnostics in your code has been overhauled, printing reports is easier than
ever, and we even have an `eyre::Report`-style wrapper you can pass around in
app-internal returns!
#### Features
* **reporter:** Overhauled return type/main/DiagnosticReport experience. ([29c1403e](https://github.com/zkat/miette/commit/29c1403efdd7fd218f240ac458fd19bba17e9551))
## 0.10.0 (2021-08-17)
Lots of goodies in this release! I'm working hard on the [1.0.0
Roadmap](https://github.com/zkat/miette/issues/10), so things are changing
pretty quick, and I thought it would be nice to release this checkpoint.
#### Bug Fixes
* **protocol:** keep the owned spans ([49151bb0](https://github.com/zkat/miette/commit/49151bb0950c0db9d2743c8fb78dcacfc27bc750))
#### Features/Breaking Changes
* **derive:** Allow anything Clone + Into to be used as a Span ([385171eb](https://github.com/zkat/miette/commit/385171eb8178ce2e7d6d2d2849b78e0f09feb721))
* **offsets:**
* nice utility function to get an offset from a Rust callsite ([26f409c5](https://github.com/zkat/miette/commit/26f409c5252c3fda5ead140eb4d5ec282f47f0f7))
* utility function for converting from line/col to offset ([75c23127](https://github.com/zkat/miette/commit/75c2312755bf714c112badf6310b2bff1633f6bc))
* more utility From impls for SourceSpan ([95200366](https://github.com/zkat/miette/commit/95200366a1639b0b729db460ae1e50cce6fee9de))
* **protocol:**
* add Source impls for Cow and Arc ([53074d34](https://github.com/zkat/miette/commit/53074d3488e1404331fc1ca3c5e068ac57e9a852))
* reference-based DiagnosticReport! ([f390520b](https://github.com/zkat/miette/commit/f390520b45823d65055f9f872016e4ee27c0c20a))
## 0.9.0 (2021-08-17)
Yay new version already! A pretty significant API change, too! ��
#### Breaking Changes
`SourceSpan`s have changed a bit: for one, they're based on offset/length now,
instead of start/end. For two, they have a new `Option` field,
`label`, which is meant to be used by reporters in different contexts. For
example, highlight snippets will use them as the labels for underlined
sections of code, while the snippet context will use the label as the "file
name" for the Source they point to.
* **protocol:** new SourceSpans with labels ([acfeb9c5](https://github.com/zkat/miette/commit/acfeb9c5b0e390c924194ee0363fc49fa8defbac))
#### Bug Fixes
* **derive:** allow unused variables for the snippets method ([f704d6a9](https://github.com/zkat/miette/commit/f704d6a9ae971dfe61fe9a0e0b4a1a7f98fd37bc))
#### Features
* **protocol:** implement From<(usize, usize)> for SourceSpan ([36b86df9](https://github.com/zkat/miette/commit/36b86df9f51984405efa6f38be8bbb984d605207))
## 0.8.1 (2021-08-17)
Just a small bump to update the readme (and docs.rs in the process) with the
new snippet derive stuff. No notable changes.
## 0.8.0 (2021-08-17)
You can full-on use `#[derive(Diagnostic)]` to define snippets now. That's a
big deal.
#### Features
* **derive:** Support for deriving snippet method (#18) ([f6e6acf2](https://github.com/zkat/miette/commit/f6e6acf2d2c301fd411c7c9c4b63a2b19aa69242))
## 0.7.0 (2021-08-16)
Welp. `0.6.0` was basically completely broken, so I tore out the
`darling`-based derive macros and rewrote the whole thing using `syn`, and
things are much better now!
There's still a few bits and bobs to add, like snippets (oof. big.), and full
help format string support (they don't quite work in enums right now), but
otherwise, this is pretty usable~
#### Features
* **derive:** improved derive support, including partial help format string support! ([9ef0dd26](https://github.com/zkat/miette/commit/9ef0dd261fa537b280f32ea6f149785a69e33938))
#### Bug Fixes
* **derive:** move to plain syn to fix darling issues ([9a78a943](https://github.com/zkat/miette/commit/9a78a943950078c879a1eb06baf819348139e1de))
## 0.6.0 (2021-08-15)
We haz a basic derive macro now!
#### Features
* **derive:** added basic derive macro ([0e770270](https://github.com/zkat/miette/commit/0e7702700de8a4cd9022d660aaf363b735943d55))
## 0.5.0 (2021-08-14)
I decided to yank some handy (optional) utilities from a project I'm using
`miette` in. These should make using it more ergonomic.
#### Features
* **utils:** various convenience utilities for creating and working with Diagnostics ([a9601368](https://github.com/zkat/miette/commit/a960136802834bd3741ef637d91f73287870b1ad))
## 0.4.0 (2021-08-11)
Time for another (still experimental!) change to `Diagnostic`. It will
probably continue to change as miette gets experimented with, until 1.0.0
stabilizes it. But for now, expect semi-regular breaking changes of this kind.
Oh and I tracked down a rogue `\n` that was messing with the default reporter
and managed to get out of it with at least some of my sanity.
#### Breaking Changes
* **protocol:** Simplify protocol return values further ([02dd1f84](https://github.com/zkat/miette/commit/02dd1f84d45c01fb4de2d31c158a7b6e08455f72), breaks [#](https://github.com/zkat/miette/issues/))
#### Bug Fixes
* **reporter:**
* fix reporter and tests... again ([d201dde4](https://github.com/zkat/miette/commit/d201dde4b559a2baa4259a0845582a5d14453c5a))
* fix extra newline after header ([0d2e3312](https://github.com/zkat/miette/commit/0d2e3312a4a262e99a131bc893097d295e59e8ca))
## 0.3.1 (2021-08-11)
This is a tiny release to fix a reporter rendering bug.
#### Bug Fixes
* **reporter:** fix missing newline before help text ([9d430b6f](https://github.com/zkat/miette/commit/9d430b6f477fd8991ce217dffdbce8fbd28dcd7e))
## 0.3.0 (2021-08-08)
This version is the result of a lot of experimentation with getting the
`Diagnostic` API right, particularly `Diagnostic::snippets()`, which is
something that should be writable in several different ways. As such, it
includes some breaking changes, but they shouldn't be too hard to figure out.
#### Breaking Changes
* **protocol:**
* improvements to snippets API ([3584dc60](https://github.com/zkat/miette/commit/3584dc600c2b8b0f84a2a0c59856da9a9dc7fbab))
* help is a single Display ref now. ([80e7dabb](https://github.com/zkat/miette/commit/80e7dabbe450d4a78ed18174e2a383a6a1ed0557))
#### Bug Fixes
* **tests:** updating tests ([60bdf47e](https://github.com/zkat/miette/commit/60bdf47e297999b48345b39ba1a3aacbbf79e6fc))
## 0.2.1 (2021-08-05)
I think this is the right thing to do re: From!
#### Bug Fixes
* **protocol:** fix the default From<:T Diagnostic> implementation to cover more cases. ([781a51f0](https://github.com/zkat/miette/commit/781a51f03765c7351a95b34e8391f6a0cf5fc37c))
## 0.2.0 (2021-08-05)
Starting to get some good feedback on the protocol and APIs, so some improvements were made.
#### Breaking changes
You might need to add `+ Send + Sync + 'static` to your `Box`
usages now, since `Diagnostic` no longer constrains on any of them.
Additionally, `Diagnostic::help()`, `Diagnostic::code()`, and `SpanContents`
have had signature changes that you'll need to adapt to.
* **protocol:** protocol improvements after getting feedback ([e955321c](https://github.com/zkat/miette/commit/e955321cbd67372dfebb71a829ddb89baf9b169a))
* **protocol:** Make use of ? and return types with Diagnostics more ergonomic ([50238d75](https://github.com/zkat/miette/commit/50238d75a2db2dccbe2ae2cba78d0dd6eac4ef2a))
## 0.1.0 (2021-08-05)
I'm really excited to put out this first release of `miette`! This version
defines the current protocol and includes a basic snippet reporter. It's fully
documented and ready to be used!
_Disclaimer_: This library is still under pretty heavy development, and you should only use this if you're interested in using something experimental. Any and all design comments and ideas are welcome over on [GitHub](https://github.com/zkat/miettee)
#### Bug Fixes
* **api:** stop re-exporting random things wtf??? ([2fb9f93c](https://github.com/zkat/miette/commit/2fb9f93cbf02c4d41a5538e98c8bea72f40c5430))
* **protocol:** use references for all return values in Diagnostic ([c3f41b97](https://github.com/zkat/miette/commit/c3f41b972da0e89220e7d9de08f420912ec8973a))
#### Features
* **protocol:** sketched out a basic protocol ([e2387ce2](https://github.com/zkat/miette/commit/e2387ce2edd4165d04f47a084f3f1492a5de8d9d))
* **reporter:** dummy reporter implementation + tests ([a437f445](https://github.com/zkat/miette/commit/a437f44511768e52cfedd856b5b1432c0716f378))
* **span:** make span end optional ([1cb0ad38](https://github.com/zkat/miette/commit/1cb0ad38524696a733f6134092ffd998f76fb142))
## 0.0.0 (2021-08-03)
Don't mind me, just parking this crate name.
miette-7.4.0/CODE_OF_CONDUCT.md 0000644 0000000 0000000 00000023234 10461020230 0013726 0 ustar 0000000 0000000 # Code of Conduct
## When Something Happens
If you see a Code of Conduct violation, follow these steps:
1. Let the person know that what they did is not appropriate and ask them to stop and/or edit their message(s) or commits.
2. That person should immediately stop the behavior and correct the issue.
3. If this doesn’t happen, or if you're uncomfortable speaking up, [contact the maintainers](#contacting-maintainers).
4. As soon as available, a maintainer will look into the issue, and take [further action (see below)](#further-enforcement), starting with a warning, then temporary block, then long-term repo or organization ban.
When reporting, please include any relevant details, links, screenshots, context, or other information that may be used to better understand and resolve the situation.
**The maintainer team will prioritize the well-being and comfort of the recipients of the violation over the comfort of the violator.** See [some examples below](#enforcement-examples).
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers of this project pledge to making participation in our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, technical preferences, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language.
* Being respectful of differing viewpoints and experiences.
* Gracefully accepting constructive feedback.
* Focusing on what is best for the community.
* Showing empathy and kindness towards other community members.
* Encouraging and raising up your peers in the project so you can all bask in hacks and glory.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity.
* Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology.
* Making light of/making mocking comments about trigger warnings and content warnings.
* Trolling, insulting/derogatory comments, and personal or political attacks.
* Public or private harassment, deliberate intimidation, or threats.
* Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent.
* Publishing private screenshots or quotes of interactions in the context of this project without all quoted users' *explicit* consent.
* Publishing of private communication that doesn't have to do with reporting harassment.
* Any of the above even when [presented as "ironic" or "joking"](https://en.wikipedia.org/wiki/Hipster_racism).
* Any attempt to present "reverse-ism" versions of the above as violations. Examples of reverse-isms are "reverse racism", "reverse sexism", "heterophobia", and "cisphobia".
* Unsolicited explanations under the assumption that someone doesn't already know it. Ask before you teach! Don't assume what people's knowledge gaps are.
* [Feigning or exaggerating surprise](https://www.recurse.com/manual#no-feigned-surprise) when someone admits to not knowing something.
* "[Well-actuallies](https://www.recurse.com/manual#no-well-actuallys)"
* Other conduct which could reasonably be considered inappropriate in a professional or community setting.
## Scope
This Code of Conduct applies both within spaces involving this project and in other spaces involving community members. This includes the repository, its Pull Requests and Issue tracker, its Twitter community, private email communications in the context of the project, and any events where members of the project are participating, as well as adjacent communities and venues affecting the project's members.
Depending on the violation, the maintainers may decide that violations of this code of conduct that have happened outside of the scope of the community may deem an individual unwelcome, and take appropriate action to maintain the comfort and safety of its members.
### Other Community Standards
As a project on GitHub, this project is additionally covered by the [GitHub Community Guidelines](https://help.github.com/articles/github-community-guidelines/).
Enforcement of those guidelines after violations overlapping with the above are the responsibility of the entities, and enforcement may happen in any or all of the services/communities.
## Maintainer Enforcement Process
Once the maintainers get involved, they will follow a documented series of steps and do their best to preserve the well-being of project members. This section covers actual concrete steps.
### Contacting Maintainers
You may get in touch with the maintainer team through any of the following methods:
* Through email:
* [coc@zkat.tech](mailto:coc@zkat.tech) (Kat Marchán)
* Through Twitter:
* [@zkat__](https://twitter.com/zkat__) (Kat Marchán)
### Further Enforcement
If you've already followed the [initial enforcement steps](#enforcement), these are the steps maintainers will take for further enforcement, as needed:
1. Repeat the request to stop.
2. If the person doubles down, they will have offending messages removed or edited by a maintainers given an official warning. The PR or Issue may be locked.
3. If the behavior continues or is repeated later, the person will be blocked from participating for 24 hours.
4. If the behavior continues or is repeated after the temporary block, a long-term (6-12mo) ban will be used.
On top of this, maintainers may remove any offending messages, images, contributions, etc, as they deem necessary.
Maintainers reserve full rights to skip any of these steps, at their discretion, if the violation is considered to be a serious and/or immediate threat to the health and well-being of members of the community. These include any threats, serious physical or verbal attacks, and other such behavior that would be completely unacceptable in any social setting that puts our members at risk.
Members expelled from events or venues with any sort of paid attendance will not be refunded.
### Who Watches the Watchers?
Maintainers and other leaders who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. These may include anything from removal from the maintainer team to a permanent ban from the community.
Additionally, as a project hosted on GitHub, [its own Codes of Conducts may be applied against maintainers of this project](#other-community-standards), externally of this project's procedures.
### Enforcement Examples
#### The Best Case
The vast majority of situations work out like this. This interaction is common, and generally positive.
> Alex: "Yeah I used X and it was really crazy!"
> Patt (not a maintainer): "Hey, could you not use that word? What about 'ridiculous' instead?"
> Alex: "oh sorry, sure." -> edits old comment to say "it was really confusing!"
#### The Maintainer Case
Sometimes, though, you need to get maintainers involved. Maintainers will do their best to resolve conflicts, but people who were harmed by something **will take priority**.
> Patt: "Honestly, sometimes I just really hate using $library and anyone who uses it probably sucks at their job."
> Alex: "Whoa there, could you dial it back a bit? There's a CoC thing about attacking folks' tech use like that."
> Patt: "I'm not attacking anyone, what's your problem?"
> Alex: "@maintainers hey uh. Can someone look at this issue? Patt is getting a bit aggro. I tried to nudge them about it, but nope."
> KeeperOfCommitBits: (on issue) "Hey Patt, maintainer here. Could you tone it down? This sort of attack is really not okay in this space."
> Patt: "Leave me alone I haven't said anything bad wtf is wrong with you."
> KeeperOfCommitBits: (deletes user's comment), "@patt I mean it. Please refer to the CoC over at (URL to this CoC) if you have questions, but you can consider this an actual warning. I'd appreciate it if you reworded your messages in this thread, since they made folks there uncomfortable. Let's try and be kind, yeah?"
> Patt: "@keeperofbits Okay sorry. I'm just frustrated and I'm kinda burnt out and I guess I got carried away. I'll DM Alex a note apologizing and edit my messages. Sorry for the trouble."
> KeeperOfCommitBits: "@patt Thanks for that. I hear you on the stress. Burnout sucks :/. Have a good one!"
#### The Nope Case
> PepeTheFrog🐸: "Hi, I am a literal actual nazi and I think white supremacists are quite fashionable."
> Patt: "NOOOOPE. OH NOPE NOPE."
> Alex: "JFC NO. NOPE. @keeperofbits NOPE NOPE LOOK HERE"
> KeeperOfCommitBits: "👀 Nope. NOPE NOPE NOPE. 🔥"
> PepeTheFrog🐸 has been banned from all organization or user repositories belonging to KeeperOfCommitBits.
## Attribution
This Code of Conduct was generated using [WeAllJS Code of Conduct Generator](https://npm.im/weallbehave), which is based on the [WeAllJS Code of
Conduct](https://wealljs.org/code-of-conduct), which is itself based on
[Contributor Covenant](http://contributor-covenant.org), version 1.4, available
at
[http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4),
and the LGBTQ in Technology Slack [Code of
Conduct](http://lgbtq.technology/coc.html).
miette-7.4.0/CONTRIBUTING.md 0000644 0000000 0000000 00000051412 10461020230 0013357 0 ustar 0000000 0000000 # Contributing
## How do I...
* [Use This Guide](#introduction)?
* Ask or Say Something? 🤔🐛😱
* [Request Support](#request-support)
* [Report an Error or Bug](#report-an-error-or-bug)
* [Request a Feature](#request-a-feature)
* Make Something? 🤓👩🏽💻📜🍳
* [Project Setup](#project-setup)
* [Contribute Documentation](#contribute-documentation)
* [Contribute Code](#contribute-code)
* Manage Something ✅🙆🏼💃👔
* [Provide Support on Issues](#provide-support-on-issues)
* [Label Issues](#label-issues)
* [Clean Up Issues and PRs](#clean-up-issues-and-prs)
* [Review Pull Requests](#review-pull-requests)
* [Merge Pull Requests](#merge-pull-requests)
* [Tag a Release](#tag-a-release)
* [Join the Project Team](#join-the-project-team)
* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻
## Introduction
Thank you so much for your interest in contributing! All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝
Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚
The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨
## Request Support
If you have a question about this project, how to use it, or just need clarification about something:
* Open an Issue at https://github.com/zkat/miette/issues
* Provide as much context as you can about what you're running into.
* Provide project and platform versions, depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it.
Once it's filed:
* The project team will [label the issue](#label-issues).
* Someone will try to have a response soon.
* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made.
## Report an Error or Bug
If you run into an error or bug with the project:
* Open an Issue at https://github.com/zkat/miette/issues
* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own.
* Provide project and platform versions, depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it.
Once it's filed:
* The project team will [label the issue](#label-issues).
* A team member will try to reproduce the issue with your provided steps. If there are no repro steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#contribute-code).
* If you or the maintainers don't respond to an issue for 30 days, the [issue will be closed](#clean-up-issues-and-prs). If you want to come back to it, reply (once, please), and we'll reopen the existing issue. Please avoid filing new issues as extensions of one you already made.
* `critical` issues may be left open, depending on perceived immediacy and severity, even past the 30 day deadline.
## Request a Feature
If the project doesn't do something you need or want it to do:
* Open an Issue at https://github.com/zkat/miette/issues
* Provide as much context as you can about what you're running into.
* Please try and be clear about why existing features and alternatives would not work for you.
Once it's filed:
* The project team will [label the issue](#label-issues).
* The project team will evaluate the feature request, possibly asking you more questions to understand its purpose and any relevant requirements. If the issue is closed, the team will convey their reasoning and suggest an alternative path forward.
* If the feature request is accepted, it will be marked for implementation with `feature-accepted`, which can then be done by either by a core team member or by anyone in the community who wants to [contribute code](#contribute-code).
Note: The team is unlikely to be able to accept every single feature request that is filed. Please understand if they need to say no.
## Project Setup
So you wanna contribute some code! That's great! This project uses GitHub Pull Requests to manage contributions, so [read up on how to fork a GitHub project and file a PR](https://guides.github.com/activities/forking) if you've never done it before.
If this seems like a lot or you aren't able to do all this setup, you might also be able to [edit the files directly](https://help.github.com/articles/editing-files-in-another-user-s-repository/) without having to do any of this setup. Yes, [even code](#contribute-code).
If you want to go the usual route and run the project locally, though:
* [Install Rust](https://www.rust-lang.org/learn/get-started)
* [Fork the project](https://guides.github.com/activities/forking/#fork)
Then in your terminal:
* `cd path/to/your/clone`
* `cargo test --features fancy`
And you should be ready to go!
**Note:** If you don't include the "fancy" feature, one of the doc-tests will fail.
## Contribute Documentation
Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies. And it's how we tell others everything they need in order to be able to use this project -- or contribute to it. So thank you in advance.
Documentation contributions of any size are welcome! Feel free to file a PR even if you're just rewording a sentence to be more clear, or fixing a spelling mistake!
To contribute documentation:
* [Set up the project](#project-setup).
* Edit or add any relevant documentation.
* Make sure your changes are formatted correctly and consistently with the rest of the documentation.
* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything.
* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(): `.
* Go to https://github.com/zkat/miette/pulls and open a new pull request with your changes.
* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing.
Once you've filed the PR:
* One or more maintainers will use GitHub's review feature to review your PR.
* If the maintainer asks for any changes, edit your changes, push, and ask for another review.
* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚
* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release)
## Contribute Code
We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others.
Code contributions of just about any size are acceptable!
The main difference between code contributions and documentation contributions is that contributing code requires inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added, unless the maintainers consider the specific tests to be either impossible, or way too much of a burden for such a contribution.
To contribute code:
* [Set up the project](#project-setup).
* Make any necessary changes to the source code.
* Include any [additional documentation](#contribute-documentation) the changes might need.
* Write tests that verify that your contribution works as expected.
* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md).
* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `(deps): PKG@VERSION`, where `` is any of the usual `conventional-changelog` prefixes, at your discretion.
* Go to https://github.com/zkat/miette/pulls and open a new pull request with your changes.
* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing.
Once you've filed the PR:
* Barring special circumstances, maintainers will not review PRs until all checks pass (Travis, AppVeyor, etc).
* One or more maintainers will use GitHub's review feature to review your PR.
* If the maintainer asks for any changes, edit your changes, push, and ask for another review. Additional tags (such as `needs-tests`) will be added depending on the review.
* If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's ok! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚
* If your PR gets accepted, it will be marked as such, and merged into the `latest` branch soon after. Your contribution will be distributed to the masses next time the maintainers [tag a release](#tag-a-release)
## Provide Support on Issues
[Needs Collaborator](#join-the-project-team): none
Helping out other users with their questions is a really awesome way of contributing to any community. It's not uncommon for most of the issues on an open source projects being support-related questions by users trying to understand something they ran into, or find their way around a known bug.
Sometimes, the `support` label will be added to things that turn out to actually be other things, like bugs or feature requests. In that case, suss out the details with the person who filed the original issue, add a comment explaining what the bug is, and change the label from `support` to `bug` or `feature`. If you can't do this yourself, @mention a maintainer so they can do it.
In order to help other folks out with their questions:
* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/zkat/miette/issues?q=is%3Aopen+is%3Aissue+label%3Asupport).
* Read through the list until you find something that you're familiar enough with to give an answer to.
* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on.
* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you.
Some notes on picking up support issues:
* Avoid responding to issues you don't know you can answer accurately.
* As much as possible, try to refer to past issues with accepted answers. Link to them from your replies with the `#123` format.
* Be kind and patient with users -- often, folks who have run into confusing things might be upset or impatient. This is ok. Try to understand where they're coming from, and if you're too uncomfortable with the tone, feel free to stay away or withdraw from the issue. (note: if the user is outright hostile or is violating the CoC, [refer to the Code of Conduct](CODE_OF_CONDUCT.md) to resolve the conflict).
## Label Issues
[Needs Collaborator](#join-the-project-team): Issue Tracker
One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily.
In order to label issues, [open up the list of unlabeled issues](https://github.com/zkat/miette/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself!
Label | Apply When | Notes
--- | --- | ---
`bug` | Cases where the code (or documentation) is behaving in a way it wasn't intended to. | If something is happening that surprises the *user* but does not go against the way the code is designed, it should use the `enhancement` label.
`critical` | Added to `bug` issues if the problem described makes the code completely unusable in a common situation. |
`documentation` | Added to issues or pull requests that affect any of the documentation for the project. | Can be combined with other labels, such as `bug` or `enhancement`.
`duplicate` | Added to issues or PRs that refer to the exact same issue as another one that's been previously labeled. | Duplicate issues should be marked and closed right away, with a message referencing the issue it's a duplicate of (with `#123`)
`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. |
`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling.
`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete.
`performance` | This issue or PR is directly related to improving performance. |
`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. |
`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority.
`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes.
`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests)
`wontfix` | Labelers may apply this label to issues that clearly have nothing at all to do with the project or are otherwise entirely outside of its scope/sphere of influence. [Committers](#join-the-project-team) may apply this label and close an issue or PR if they decide to pass on an otherwise relevant issue. | The issue or PR should be closed as soon as the label is applied, and a clear explanation provided of why the label was used. Contributors are free to contest the labeling, but the decision ultimately falls on committers as to whether to accept something or not.
## Clean Up Issues and PRs
[Needs Collaborator](#join-the-project-team): Issue Tracker
Issues and PRs can go stale after a while. Maybe they're abandoned. Maybe the team will just plain not have time to address them any time soon.
In these cases, they should be closed until they're brought up again or the interaction starts over.
To clean up issues and PRs:
* Search the issue tracker for issues or PRs, and add the term `updated:<=YYYY-MM-DD`, where the date is 30 days before today.
* Go through each issue *from oldest to newest*, and close them if **all of the following are true**:
* not opened by a maintainer
* not marked as `critical`
* not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available)
* no explicit messages in the comments asking for it to be left open
* does not belong to a milestone
* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/zkat/miette/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details."
## Review Pull Requests
[Needs Collaborator](#join-the-project-team): Issue Tracker
While anyone can comment on a PR, add feedback, etc, PRs are only *approved* by team members with Issue Tracker or higher permissions.
PR reviews use [GitHub's own review feature](https://help.github.com/articles/about-pull-request-reviews/), which manages comments, approval, and review iteration.
Some notes:
* You may ask for minor changes ("nitpicks"), but consider whether they are really blockers to merging: try to err on the side of "approve, with comments".
* *ALL PULL REQUESTS* should be covered by a test: either by a previously-failing test, an existing test that covers the entire functionality of the submitted code, or new tests to verify any new/changed behavior. All tests must also pass and follow established conventions. Test coverage should not drop, unless the specific case is considered reasonable by maintainers.
* Please make sure you're familiar with the code or documentation being updated, unless it's a minor change (spellchecking, minor formatting, etc). You may @mention another project member who you think is better suited for the review, but still provide a non-approving review of your own.
* Be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) -- always respond with respect, be understanding, but don't feel like you need to sacrifice your standards for their sake, either. Just don't be a jerk about it?
## Merge Pull Requests
[Needs Collaborator](#join-the-project-team): Committer
TBD - need to hash out a bit more of this process.
## Tag A Release
[Needs Collaborator](#join-the-project-team): Committer
TBD - need to hash out a bit more of this process. The most important bit here is probably that all tests must pass, and tags must use [semver](https://semver.org).
## Join the Project Team
### Ways to Join
There are many ways to contribute! Most of them don't require any official status unless otherwise noted. That said, there's a couple of positions that grant special repository abilities, and this section describes how they're granted and what they do.
All of the below positions are granted based on the project team's needs, as well as their consensus opinion about whether they would like to work with the person and think that they would fit well into that position. The process is relatively informal, and it's likely that people who express interest in participating can just be granted the permissions they'd like.
You can spot a collaborator on the repo by looking for the `[Collaborator]` or `[Owner]` tags next to their names.
Permission | Description
--- | ---
Issue Tracker | Granted to contributors who express a strong interest in spending time on the project's issue tracker. These tasks are mainly [labeling issues](#label-issues), [cleaning up old ones](#clean-up-issues-and-prs), and [reviewing pull requests](#review-pull-requests), as well as all the usual things non-team-member contributors can do. Issue handlers should not merge pull requests, tag releases, or directly commit code themselves: that should still be done through the usual pull request process. Becoming an Issue Handler means the project team trusts you to understand enough of the team's process and context to implement it on the issue tracker.
Committer | Granted to contributors who want to handle the actual pull request merges, tagging new versions, etc. Committers should have a good level of familiarity with the codebase, and enough context to understand the implications of various changes, as well as a good sense of the will and expectations of the project team.
Admin/Owner | Granted to people ultimately responsible for the project, its community, etc.
## Attribution
This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)!
miette-7.4.0/Cargo.lock 0000644 00000057636 00000000001 0010327 0 ustar # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "addr2line"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
[[package]]
name = "backtrace"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]]
name = "backtrace-ext"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50"
dependencies = [
"backtrace",
]
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "basic-toml"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5"
dependencies = [
"serde",
]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
]
[[package]]
name = "deranged"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
dependencies = [
"powerfmt",
]
[[package]]
name = "dissimilar"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632"
[[package]]
name = "equivalent"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "flate2"
version = "1.0.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "futures"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]]
name = "futures-io"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-sink"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]]
name = "futures-util"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-core",
"futures-sink",
"futures-task",
"pin-project-lite",
"pin-utils",
]
[[package]]
name = "gimli"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "indenter"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]]
name = "is_ci"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45"
[[package]]
name = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "line-wrap"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
dependencies = [
"safemem",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "memchr"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "miette"
version = "7.4.0"
dependencies = [
"backtrace",
"backtrace-ext",
"cfg-if",
"futures",
"indenter",
"lazy_static",
"miette-derive",
"owo-colors",
"regex",
"rustversion",
"semver",
"serde",
"serde_json",
"strip-ansi-escapes",
"supports-color",
"supports-hyperlinks",
"supports-unicode",
"syn",
"syntect",
"terminal_size",
"textwrap",
"thiserror",
"trybuild",
"unicode-width",
]
[[package]]
name = "miette-derive"
version = "7.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "miniz_oxide"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
dependencies = [
"adler",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "object"
version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "onig"
version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [
"bitflags 1.3.2",
"libc",
"once_cell",
"onig_sys",
]
[[package]]
name = "onig_sys"
version = "69.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7"
dependencies = [
"cc",
"pkg-config",
]
[[package]]
name = "owo-colors"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f"
[[package]]
name = "pin-project-lite"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb"
[[package]]
name = "plist"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef"
dependencies = [
"base64",
"indexmap",
"line-wrap",
"quick-xml",
"serde",
"time",
]
[[package]]
name = "powerfmt"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "proc-macro2"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-xml"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax 0.8.2",
]
[[package]]
name = "regex-automata"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.2",
]
[[package]]
name = "regex-syntax"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "regex-syntax"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]]
name = "rustc-demangle"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
dependencies = [
"bitflags 2.4.2",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "rustversion"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "semver"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
[[package]]
name = "serde"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.196"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "strip-ansi-escapes"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55ff8ef943b384c414f54aefa961dd2bd853add74ec75e7ac74cf91dba62bcfa"
dependencies = [
"vte",
]
[[package]]
name = "supports-color"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f"
dependencies = [
"is_ci",
]
[[package]]
name = "supports-hyperlinks"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c0a1e5168041f5f3ff68ff7d95dcb9c8749df29f6e7e89ada40dd4c9de404ee"
[[package]]
name = "supports-unicode"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
[[package]]
name = "syn"
version = "2.0.48"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syntect"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91"
dependencies = [
"bincode",
"bitflags 1.3.2",
"flate2",
"fnv",
"once_cell",
"onig",
"plist",
"regex-syntax 0.7.5",
"serde",
"serde_json",
"thiserror",
"walkdir",
"yaml-rust",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "terminal_size"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f599bd7ca042cfdf8f4512b277c02ba102247820f9d9d4a9f521f496751a6ef"
dependencies = [
"rustix",
"windows-sys 0.59.0",
]
[[package]]
name = "textwrap"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
dependencies = [
"unicode-linebreak",
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "time"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
"time-macros",
]
[[package]]
name = "time-core"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774"
dependencies = [
"num-conv",
"time-core",
]
[[package]]
name = "trybuild"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a9d3ba662913483d6722303f619e75ea10b7855b0f8e0d72799cf8621bb488f"
dependencies = [
"basic-toml",
"dissimilar",
"glob",
"once_cell",
"serde",
"serde_derive",
"serde_json",
"termcolor",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-linebreak"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "utf8parse"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "vte"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197"
dependencies = [
"utf8parse",
"vte_generate_state_changes",
]
[[package]]
name = "vte_generate_state_changes"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "walkdir"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
miette-7.4.0/Cargo.toml 0000644 00000006260 00000000001 0010335 0 ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.70.0"
name = "miette"
version = "7.4.0"
authors = ["Kat Marchán "]
build = false
exclude = [
"images/",
"tests/",
"miette-derive/",
]
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "Fancy diagnostic reporting library and protocol for us mere mortals who aren't compiler hackers."
documentation = "https://docs.rs/miette"
readme = "README.md"
categories = ["rust-patterns"]
license = "Apache-2.0"
repository = "https://github.com/zkat/miette"
[package.metadata.docs.rs]
all-features = true
[lib]
name = "miette"
path = "src/lib.rs"
[[example]]
name = "serde_json"
path = "examples/serde_json.rs"
required-features = ["fancy"]
[dependencies.backtrace]
version = "0.3.69"
optional = true
[dependencies.backtrace-ext]
version = "0.2.1"
optional = true
[dependencies.cfg-if]
version = "1.0.0"
[dependencies.miette-derive]
version = "=7.4.0"
optional = true
[dependencies.owo-colors]
version = "4.0.0"
optional = true
[dependencies.serde]
version = "1.0.196"
features = ["derive"]
optional = true
[dependencies.supports-color]
version = "3.0.0"
optional = true
[dependencies.supports-hyperlinks]
version = "3.0.0"
optional = true
[dependencies.supports-unicode]
version = "3.0.0"
optional = true
[dependencies.syntect]
version = "5.1.0"
optional = true
[dependencies.terminal_size]
version = "0.4.0"
optional = true
[dependencies.textwrap]
version = "0.16.0"
features = [
"unicode-linebreak",
"unicode-width",
]
optional = true
default-features = false
[dependencies.thiserror]
version = "1.0.56"
[dependencies.unicode-width]
version = "0.1.11"
[dev-dependencies.futures]
version = "0.3"
default-features = false
[dev-dependencies.indenter]
version = "0.3.3"
[dev-dependencies.lazy_static]
version = "1.4"
[dev-dependencies.regex]
version = "1.10"
[dev-dependencies.rustversion]
version = "1.0"
[dev-dependencies.semver]
version = "1.0.21"
[dev-dependencies.serde]
version = "1.0.196"
features = ["derive"]
[dev-dependencies.serde_json]
version = "1.0.113"
[dev-dependencies.strip-ansi-escapes]
version = "0.2.0"
[dev-dependencies.syn]
version = "2.0.48"
features = ["full"]
[dev-dependencies.trybuild]
version = "1.0.89"
features = ["diff"]
[features]
default = ["derive"]
derive = ["dep:miette-derive"]
fancy = [
"fancy-no-backtrace",
"dep:backtrace",
"dep:backtrace-ext",
]
fancy-base = [
"dep:owo-colors",
"dep:textwrap",
]
fancy-no-backtrace = [
"fancy-base",
"dep:terminal_size",
"dep:supports-hyperlinks",
"dep:supports-color",
"dep:supports-unicode",
]
fancy-no-syscall = ["fancy-base"]
no-format-args-capture = []
syntect-highlighter = [
"fancy-no-backtrace",
"dep:syntect",
]
miette-7.4.0/Cargo.toml.orig 0000644 0000000 0000000 00000004342 10461020230 0014015 0 ustar 0000000 0000000 [package]
name = "miette"
version = "7.4.0"
authors = ["Kat Marchán "]
description = "Fancy diagnostic reporting library and protocol for us mere mortals who aren't compiler hackers."
categories = ["rust-patterns"]
repository = "https://github.com/zkat/miette"
documentation = "https://docs.rs/miette"
license = "Apache-2.0"
readme = "README.md"
edition = "2018"
rust-version = "1.70.0"
exclude = ["images/", "tests/", "miette-derive/"]
[dependencies]
thiserror = "1.0.56"
miette-derive = { path = "miette-derive", version = "=7.4.0", optional = true }
unicode-width = "0.1.11"
cfg-if = "1.0.0"
owo-colors = { version = "4.0.0", optional = true }
textwrap = { version = "0.16.0", default-features = false, features = ["unicode-linebreak", "unicode-width"], optional = true }
supports-hyperlinks = { version = "3.0.0", optional = true }
supports-color = { version = "3.0.0", optional = true }
supports-unicode = { version = "3.0.0", optional = true }
backtrace = { version = "0.3.69", optional = true }
terminal_size = { version = "0.4.0", optional = true }
backtrace-ext = { version = "0.2.1", optional = true }
serde = { version = "1.0.196", features = ["derive"], optional = true }
syntect = { version = "5.1.0", optional = true }
[dev-dependencies]
semver = "1.0.21"
# Eyre devdeps
futures = { version = "0.3", default-features = false }
indenter = "0.3.3"
rustversion = "1.0"
trybuild = { version = "1.0.89", features = ["diff"] }
syn = { version = "2.0.48", features = ["full"] }
regex = "1.10"
lazy_static = "1.4"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
strip-ansi-escapes = "0.2.0"
[features]
default = ["derive"]
derive = ["dep:miette-derive"]
no-format-args-capture = []
fancy-base = [
"dep:owo-colors",
"dep:textwrap",
]
fancy-no-syscall = [
"fancy-base",
]
fancy-no-backtrace = [
"fancy-base",
"dep:terminal_size",
"dep:supports-hyperlinks",
"dep:supports-color",
"dep:supports-unicode",
]
fancy = ["fancy-no-backtrace", "dep:backtrace", "dep:backtrace-ext"]
syntect-highlighter = ["fancy-no-backtrace", "dep:syntect"]
[workspace]
members = ["miette-derive"]
[package.metadata.docs.rs]
all-features = true
[[example]]
name = "serde_json"
required-features = ["fancy"]
miette-7.4.0/LICENSE 0000644 0000000 0000000 00000026136 10461020230 0012140 0 ustar 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
miette-7.4.0/Makefile.toml 0000644 0000000 0000000 00000000575 10461020230 0013544 0 ustar 0000000 0000000 [tasks.changelog]
workspace=false
install_crate="git-cliff"
command = "git-cliff"
args = ["--prepend", "CHANGELOG.md", "-u", "--tag", "${@}"]
[tasks.release]
workspace=false
install_crate="cargo-release"
command = "cargo"
args = ["release", "--workspace", "${@}"]
[tasks.readme]
workspace=false
install_crate="cargo-readme"
command = "cargo"
args = ["readme", "-o", "README.md"]
miette-7.4.0/README.md 0000644 0000000 0000000 00000057237 10461020230 0012420 0 ustar 0000000 0000000
# `miette`
You run miette? You run her code like the software? Oh. Oh! Error code for
coder! Error code for One Thousand Lines!
### About
`miette` is a diagnostic library for Rust. It includes a series of
traits/protocols that allow you to hook into its error reporting facilities,
and even write your own error reports! It lets you define error types that
can print out like this (or in any format you like!):
> **NOTE: You must enable the `"fancy"` crate feature to get fancy report
> output like in the screenshots above.** You should only do this in your
> toplevel crate, as the fancy feature pulls in a number of dependencies that
> libraries and such might not want.
### Table of Contents
- [About](#about)
- [Features](#features)
- [Installing](#installing)
- [Example](#example)
- [Using](#using)
- [... in libraries](#-in-libraries)
- [... in application code](#-in-application-code)
- [... in `main()`](#-in-main)
- [... diagnostic code URLs](#-diagnostic-code-urls)
- [... snippets](#-snippets)
- [... help text](#-help-text)
- [... severity level](#-severity-level)
- [... multiple related errors](#-multiple-related-errors)
- [... delayed source code](#-delayed-source-code)
- [... handler options](#-handler-options)
- [... dynamic diagnostics](#-dynamic-diagnostics)
- [... syntax highlighting](#-syntax-highlighting)
- [... collection of labels](#-collection-of-labels)
- [Acknowledgements](#acknowledgements)
- [License](#license)
### Features
- Generic [`Diagnostic`] protocol, compatible (and dependent on)
[`std::error::Error`].
- Unique error codes on every [`Diagnostic`].
- Custom links to get more details on error codes.
- Super handy derive macro for defining diagnostic metadata.
- Replacements for [`anyhow`](https://docs.rs/anyhow)/[`eyre`](https://docs.rs/eyre)
types [`Result`], [`Report`] and the [`miette!`] macro for the
`anyhow!`/`eyre!` macros.
- Generic support for arbitrary [`SourceCode`]s for snippet data, with
default support for `String`s included.
The `miette` crate also comes bundled with a default [`ReportHandler`] with
the following features:
- Fancy graphical [diagnostic output](#about), using ANSI/Unicode text
- single- and multi-line highlighting support
- Screen reader/braille support, gated on [`NO_COLOR`](http://no-color.org/),
and other heuristics.
- Fully customizable graphical theming (or overriding the printers
entirely).
- Cause chain printing
- Turns diagnostic codes into links in [supported terminals](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda).
### Installing
```sh
$ cargo add miette
```
If you want to use the fancy printer in all these screenshots:
```sh
$ cargo add miette --features fancy
```
### Example
```rust
/*
You can derive a `Diagnostic` from any `std::error::Error` type.
`thiserror` is a great way to define them, and plays nicely with `miette`!
*/
use miette::{Diagnostic, SourceSpan};
use thiserror::Error;
#[derive(Error, Debug, Diagnostic)]
#[error("oops!")]
#[diagnostic(
code(oops::my::bad),
url(docsrs),
help("try doing it better next time?")
)]
struct MyBad {
// The Source that we're gonna be printing snippets out of.
// This can be a String if you don't have or care about file names.
#[source_code]
src: NamedSource,
// Snippets and highlights can be included in the diagnostic!
#[label("This bit here")]
bad_bit: SourceSpan,
}
/*
Now let's define a function!
Use this `Result` type (or its expanded version) as the return type
throughout your app (but NOT your libraries! Those should always return
concrete types!).
*/
use miette::{NamedSource, Result};
fn this_fails() -> Result<()> {
// You can use plain strings as a `Source`, or anything that implements
// the one-method `Source` trait.
let src = "source\n text\n here".to_string();
Err(MyBad {
src: NamedSource::new("bad_file.rs", src),
bad_bit: (9, 4).into(),
})?;
Ok(())
}
/*
Now to get everything printed nicely, just return a `Result<()>`
and you're all set!
Note: You can swap out the default reporter for a custom one using
`miette::set_hook()`
*/
fn pretend_this_is_main() -> Result<()> {
// kaboom~
this_fails()?;
Ok(())
}
```
And this is the output you'll get if you run this program:
### Using
#### ... in libraries
`miette` is _fully compatible_ with library usage. Consumers who don't know
about, or don't want, `miette` features can safely use its error types as
regular [`std::error::Error`].
We highly recommend using something like [`thiserror`](https://docs.rs/thiserror)
to define unique error types and error wrappers for your library.
While `miette` integrates smoothly with `thiserror`, it is _not required_.
If you don't want to use the [`Diagnostic`] derive macro, you can implement
the trait directly, just like with `std::error::Error`.
```rust
// lib/error.rs
use miette::{Diagnostic, SourceSpan};
use thiserror::Error;
#[derive(Error, Diagnostic, Debug)]
pub enum MyLibError {
#[error(transparent)]
#[diagnostic(code(my_lib::io_error))]
IoError(#[from] std::io::Error),
#[error("Oops it blew up")]
#[diagnostic(code(my_lib::bad_code))]
BadThingHappened,
#[error(transparent)]
// Use `#[diagnostic(transparent)]` to wrap another [`Diagnostic`]. You won't see labels otherwise
#[diagnostic(transparent)]
AnotherError(#[from] AnotherError),
}
#[derive(Error, Diagnostic, Debug)]
#[error("another error")]
pub struct AnotherError {
#[label("here")]
pub at: SourceSpan
}
```
Then, return this error type from all your fallible public APIs. It's a best
practice to wrap any "external" error types in your error `enum` instead of
using something like [`Report`] in a library.
#### ... in application code
Application code tends to work a little differently than libraries. You
don't always need or care to define dedicated error wrappers for errors
coming from external libraries and tools.
For this situation, `miette` includes two tools: [`Report`] and
[`IntoDiagnostic`]. They work in tandem to make it easy to convert regular
`std::error::Error`s into [`Diagnostic`]s. Additionally, there's a
[`Result`] type alias that you can use to be more terse.
When dealing with non-`Diagnostic` types, you'll want to
`.into_diagnostic()` them:
```rust
// my_app/lib/my_internal_file.rs
use miette::{IntoDiagnostic, Result};
use semver::Version;
pub fn some_tool() -> Result {
"1.2.x".parse().into_diagnostic()
}
```
`miette` also includes an `anyhow`/`eyre`-style `Context`/`WrapErr` traits
that you can import to add ad-hoc context messages to your `Diagnostic`s, as
well, though you'll still need to use `.into_diagnostic()` to make use of
it:
```rust
// my_app/lib/my_internal_file.rs
use miette::{IntoDiagnostic, Result, WrapErr};
use semver::Version;
pub fn some_tool() -> Result {
"1.2.x"
.parse()
.into_diagnostic()
.wrap_err("Parsing this tool's semver version failed.")
}
```
To construct your own simple adhoc error use the [miette!] macro:
```rust
// my_app/lib/my_internal_file.rs
use miette::{miette, Result};
use semver::Version;
pub fn some_tool() -> Result {
let version = "1.2.x";
version
.parse()
.map_err(|_| miette!("Invalid version {}", version))
}
```
There are also similar [bail!] and [ensure!] macros.
#### ... in `main()`
`main()` is just like any other part of your application-internal code. Use
`Result` as your return value, and it will pretty-print your diagnostics
automatically.
> **NOTE:** You must enable the `"fancy"` crate feature to get fancy report
> output like in the screenshots here.** You should only do this in your
> toplevel crate, as the fancy feature pulls in a number of dependencies that
> libraries and such might not want.
```rust
use miette::{IntoDiagnostic, Result};
use semver::Version;
fn pretend_this_is_main() -> Result<()> {
let version: Version = "1.2.x".parse().into_diagnostic()?;
println!("{}", version);
Ok(())
}
```
Please note: in order to get fancy diagnostic rendering with all the pretty
colors and arrows, you should install `miette` with the `fancy` feature
enabled:
```toml
miette = { version = "X.Y.Z", features = ["fancy"] }
```
Another way to display a diagnostic is by printing them using the debug formatter.
This is, in fact, what returning diagnostics from main ends up doing.
To do it yourself, you can write the following:
```rust
use miette::{IntoDiagnostic, Result};
use semver::Version;
fn just_a_random_function() {
let version_result: Result = "1.2.x".parse().into_diagnostic();
match version_result {
Err(e) => println!("{:?}", e),
Ok(version) => println!("{}", version),
}
}
```
#### ... diagnostic code URLs
`miette` supports providing a URL for individual diagnostics. This URL will
be displayed as an actual link in supported terminals, like so:
To use this, you can add a `url()` sub-param to your `#[diagnostic]`
attribute:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Error, Diagnostic, Debug)]
#[error("kaboom")]
#[diagnostic(
code(my_app::my_error),
// You can do formatting!
url("https://my_website.com/error_codes#{}", self.code().unwrap())
)]
struct MyErr;
```
Additionally, if you're developing a library and your error type is exported
from your crate's top level, you can use a special `url(docsrs)` option
instead of manually constructing the URL. This will automatically create a
link to this diagnostic on `docs.rs`, so folks can just go straight to your
(very high quality and detailed!) documentation on this diagnostic:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Error, Diagnostic, Debug)]
#[diagnostic(
code(my_app::my_error),
// Will link users to https://docs.rs/my_crate/0.0.0/my_crate/struct.MyErr.html
url(docsrs)
)]
#[error("kaboom")]
struct MyErr;
```
#### ... snippets
Along with its general error handling and reporting features, `miette` also
includes facilities for adding error spans/annotations/labels to your
output. This can be very useful when an error is syntax-related, but you can
even use it to print out sections of your own source code!
To achieve this, `miette` defines its own lightweight [`SourceSpan`] type.
This is a basic byte-offset and length into an associated [`SourceCode`]
and, along with the latter, gives `miette` all the information it needs to
pretty-print some snippets! You can also use your own `Into`
types as label spans.
The easiest way to define errors like this is to use the
`derive(Diagnostic)` macro:
```rust
use miette::{Diagnostic, SourceSpan};
use thiserror::Error;
#[derive(Diagnostic, Debug, Error)]
#[error("oops")]
#[diagnostic(code(my_lib::random_error))]
pub struct MyErrorType {
// The `Source` that miette will use.
#[source_code]
src: String,
// This will underline/mark the specific code inside the larger
// snippet context.
#[label = "This is the highlight"]
err_span: SourceSpan,
// You can add as many labels as you want.
// They'll be rendered sequentially.
#[label("This is bad")]
snip2: (usize, usize), // `(usize, usize)` is `Into`!
// Snippets can be optional, by using Option:
#[label("some text")]
snip3: Option,
// with or without label text
#[label]
snip4: Option,
}
```
#### ... help text
`miette` provides two facilities for supplying help text for your errors:
The first is the `#[help()]` format attribute that applies to structs or
enum variants:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Diagnostic, Error)]
#[error("welp")]
#[diagnostic(help("try doing this instead"))]
struct Foo;
```
The other is by programmatically supplying the help text as a field to
your diagnostic:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Diagnostic, Error)]
#[error("welp")]
#[diagnostic()]
struct Foo {
#[help]
advice: Option, // Can also just be `String`
}
let err = Foo {
advice: Some("try doing this instead".to_string()),
};
```
#### ... severity level
`miette` provides a way to set the severity level of a diagnostic.
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Diagnostic, Error)]
#[error("welp")]
#[diagnostic(severity(Warning))]
struct Foo;
```
#### ... multiple related errors
`miette` supports collecting multiple errors into a single diagnostic, and
printing them all together nicely.
To do so, use the `#[related]` tag on any `IntoIter` field in your
`Diagnostic` type:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Error, Diagnostic)]
#[error("oops")]
struct MyError {
#[related]
others: Vec,
}
```
#### ... delayed source code
Sometimes it makes sense to add source code to the error message later.
One option is to use [`with_source_code()`](Report::with_source_code)
method for that:
```rust
use miette::{Diagnostic, SourceSpan};
use thiserror::Error;
#[derive(Diagnostic, Debug, Error)]
#[error("oops")]
#[diagnostic()]
pub struct MyErrorType {
// Note: label but no source code
#[label]
err_span: SourceSpan,
}
fn do_something() -> miette::Result<()> {
// This function emits actual error with label
return Err(MyErrorType {
err_span: (7..11).into(),
})?;
}
fn main() -> miette::Result<()> {
do_something().map_err(|error| {
// And this code provides the source code for inner error
error.with_source_code(String::from("source code"))
})
}
```
Also source code can be provided by a wrapper type. This is especially
useful in combination with `related`, when multiple errors should be
emitted at the same time:
```rust
use miette::{Diagnostic, Report, SourceSpan};
use thiserror::Error;
#[derive(Diagnostic, Debug, Error)]
#[error("oops")]
#[diagnostic()]
pub struct InnerError {
// Note: label but no source code
#[label]
err_span: SourceSpan,
}
#[derive(Diagnostic, Debug, Error)]
#[error("oops: multiple errors")]
#[diagnostic()]
pub struct MultiError {
// Note source code by no labels
#[source_code]
source_code: String,
// The source code above is used for these errors
#[related]
related: Vec,
}
fn do_something() -> Result<(), Vec> {
Err(vec![
InnerError {
err_span: (0..6).into(),
},
InnerError {
err_span: (7..11).into(),
},
])
}
fn main() -> miette::Result<()> {
do_something().map_err(|err_list| MultiError {
source_code: "source code".into(),
related: err_list,
})?;
Ok(())
}
```
#### ... Diagnostic-based error sources.
When one uses the `#[source]` attribute on a field, that usually comes
from `thiserror`, and implements a method for
[`std::error::Error::source`]. This works in many cases, but it's lossy:
if the source of the diagnostic is a diagnostic itself, the source will
simply be treated as an `std::error::Error`.
While this has no effect on the existing _reporters_, since they don't use
that information right now, APIs who might want this information will have
no access to it.
If it's important for you for this information to be available to users,
you can use `#[diagnostic_source]` alongside `#[source]`. Not that you
will likely want to use _both_:
```rust
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Diagnostic, Error)]
#[error("MyError")]
struct MyError {
#[source]
#[diagnostic_source]
the_cause: OtherError,
}
#[derive(Debug, Diagnostic, Error)]
#[error("OtherError")]
struct OtherError;
```
#### ... handler options
[`MietteHandler`] is the default handler, and is very customizable. In
most cases, you can simply use [`MietteHandlerOpts`] to tweak its behavior
instead of falling back to your own custom handler.
Usage is like so:
```rust
miette::set_hook(Box::new(|_| {
Box::new(
miette::MietteHandlerOpts::new()
.terminal_links(true)
.unicode(false)
.context_lines(3)
.tab_width(4)
.break_words(true)
.build(),
)
}))
```
See the docs for [`MietteHandlerOpts`] for more details on what you can
customize!
#### ... dynamic diagnostics
If you...
- ...don't know all the possible errors upfront
- ...need to serialize/deserialize errors
then you may want to use [`miette!`], [`diagnostic!`] macros or
[`MietteDiagnostic`] directly to create diagnostic on the fly.
```rust
let source = "2 + 2 * 2 = 8".to_string();
let report = miette!(
labels = vec![
LabeledSpan::at(12..13, "this should be 6"),
],
help = "'*' has greater precedence than '+'",
"Wrong answer"
).with_source_code(source);
println!("{:?}", report)
```
#### ... syntax highlighting
`miette` can be configured to highlight syntax in source code snippets.
To use the built-in highlighting functionality, you must enable the
`syntect-highlighter` crate feature. When this feature is enabled, `miette` will
automatically use the [`syntect`] crate to highlight the `#[source_code]`
field of your [`Diagnostic`].
Syntax detection with [`syntect`] is handled by checking 2 methods on the [`SpanContents`] trait, in order:
* [`language()`](SpanContents::language) - Provides the name of the language
as a string. For example `"Rust"` will indicate Rust syntax highlighting.
You can set the language of the [`SpanContents`] produced by a
[`NamedSource`] via the [`with_language`](NamedSource::with_language)
method.
* [`name()`](SpanContents::name) - In the absence of an explicitly set
language, the name is assumed to contain a file name or file path.
The highlighter will check for a file extension at the end of the name and
try to guess the syntax from that.
If you want to use a custom highlighter, you can provide a custom
implementation of the [`Highlighter`](highlighters::Highlighter)
trait to [`MietteHandlerOpts`] by calling the
[`with_syntax_highlighting`](MietteHandlerOpts::with_syntax_highlighting)
method. See the [`highlighters`] module docs for more details.
#### ... collection of labels
When the number of labels is unknown, you can use a collection of `SourceSpan`
(or any type convertible into `SourceSpan`). For this, add the `collection`
parameter to `label` and use any type than can be iterated over for the field.
```rust
#[derive(Debug, Diagnostic, Error)]
#[error("oops!")]
struct MyError {
#[label("main issue")]
primary_span: SourceSpan,
#[label(collection, "related to this")]
other_spans: Vec>,
}
let report: miette::Report = MyError {
primary_span: (6, 9).into(),
other_spans: vec![19..26, 30..41],
}.into();
println!("{:?}", report.with_source_code("About something or another or yet another ...".to_string()));
```
A collection can also be of `LabeledSpan` if you want to have different text
for different labels. Labels with no text will use the one from the `label`
attribute
```rust
#[derive(Debug, Diagnostic, Error)]
#[error("oops!")]
struct MyError {
#[label("main issue")]
primary_span: SourceSpan,
#[label(collection, "related to this")]
other_spans: Vec, // LabeledSpan
}
let report: miette::Report = MyError {
primary_span: (6, 9).into(),
other_spans: vec![
LabeledSpan::new(None, 19, 7), // Use default text `related to this`
LabeledSpan::new(Some("and also this".to_string()), 30, 11), // Use specific text
],
}.into();
println!("{:?}", report.with_source_code("About something or another or yet another ...".to_string()));
```
### MSRV
This crate requires rustc 1.70.0 or later.
### Acknowledgements
`miette` was not developed in a void. It owes enormous credit to various
other projects and their authors:
- [`anyhow`](http://crates.io/crates/anyhow) and [`color-eyre`](https://crates.io/crates/color-eyre):
these two enormously influential error handling libraries have pushed
forward the experience of application-level error handling and error
reporting. `miette`'s `Report` type is an attempt at a very very rough
version of their `Report` types.
- [`thiserror`](https://crates.io/crates/thiserror) for setting the standard
for library-level error definitions, and for being the inspiration behind
`miette`'s derive macro.
- `rustc` and [@estebank](https://github.com/estebank) for their
state-of-the-art work in compiler diagnostics.
- [`ariadne`](https://crates.io/crates/ariadne) for pushing forward how
_pretty_ these diagnostics can really look!
### License
`miette` is released to the Rust community under the [Apache license
2.0](./LICENSE).
It also includes code taken from [`eyre`](https://github.com/yaahc/eyre),
and some from [`thiserror`](https://github.com/dtolnay/thiserror), also
under the Apache License. Some code is taken from
[`ariadne`](https://github.com/zesterer/ariadne), which is MIT licensed.
[`miette!`]: https://docs.rs/miette/latest/miette/macro.miette.html
[`diagnostic!`]: https://docs.rs/miette/latest/miette/macro.diagnostic.html
[`std::error::Error`]: https://doc.rust-lang.org/nightly/std/error/trait.Error.html
[`Diagnostic`]: https://docs.rs/miette/latest/miette/trait.Diagnostic.html
[`IntoDiagnostic`]: https://docs.rs/miette/latest/miette/trait.IntoDiagnostic.html
[`MietteHandlerOpts`]: https://docs.rs/miette/latest/miette/struct.MietteHandlerOpts.html
[`MietteHandler`]: https://docs.rs/miette/latest/miette/struct.MietteHandler.html
[`MietteDiagnostic`]: https://docs.rs/miette/latest/miette/struct.MietteDiagnostic.html
[`Report`]: https://docs.rs/miette/latest/miette/struct.Report.html
[`ReportHandler`]: https://docs.rs/miette/latest/miette/trait.ReportHandler.html
[`Result`]: https://docs.rs/miette/latest/miette/type.Result.html
[`SourceCode`]: https://docs.rs/miette/latest/miette/trait.SourceCode.html
[`SourceSpan`]: https://docs.rs/miette/latest/miette/struct.SourceSpan.html
miette-7.4.0/README.tpl 0000644 0000000 0000000 00000002020 10461020230 0012573 0 ustar 0000000 0000000
# `{{crate}}`
{{readme}}
[`miette!`]: https://docs.rs/miette/latest/miette/macro.miette.html
[`diagnostic!`]: https://docs.rs/miette/latest/miette/macro.diagnostic.html
[`std::error::Error`]: https://doc.rust-lang.org/nightly/std/error/trait.Error.html
[`Diagnostic`]: https://docs.rs/miette/latest/miette/trait.Diagnostic.html
[`IntoDiagnostic`]: https://docs.rs/miette/latest/miette/trait.IntoDiagnostic.html
[`MietteHandlerOpts`]: https://docs.rs/miette/latest/miette/struct.MietteHandlerOpts.html
[`MietteHandler`]: https://docs.rs/miette/latest/miette/struct.MietteHandler.html
[`MietteDiagnostic`]: https://docs.rs/miette/latest/miette/struct.MietteDiagnostic.html
[`Report`]: https://docs.rs/miette/latest/miette/struct.Report.html
[`ReportHandler`]: https://docs.rs/miette/latest/miette/trait.ReportHandler.html
[`Result`]: https://docs.rs/miette/latest/miette/type.Result.html
[`SourceCode`]: https://docs.rs/miette/latest/miette/trait.SourceCode.html
[`SourceSpan`]: https://docs.rs/miette/latest/miette/struct.SourceSpan.html
miette-7.4.0/cliff.toml 0000644 0000000 0000000 00000003552 10461020230 0013110 0 ustar 0000000 0000000 # configuration file for git-cliff (0.1.0)
[changelog]
# changelog header
header = """
# `miette` Release Changelog
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## {{ version | replace(from="v", to="") }} ({{ timestamp | date(format="%Y-%m-%d") }})
{% else %}\
## Unreleased
{% endif %}\
{% for group, commits in commits | filter(attribute="scope") | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
{% if commit.scope %}\
* **{{ commit.scope }}:** {{ commit.message }} ([{{ commit.id | truncate(length=8, end="") }}](https://github.com/zkat/miette/commit/{{ commit.id }}))
{%- if commit.breaking %}
* **BREAKING CHANGE**: {{ commit.breaking_description }}
{%- endif %}\
{% endif %}\
{% endfor %}
{% endfor %}
"""
# remove the leading and trailing whitespace from the template
trim = false
# changelog footer
# footer = """
#
# """
[git]
# allow only conventional commits
# https://www.conventionalcommits.org
conventional_commits = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat*", group = "Features"},
{ message = "^fix*", group = "Bug Fixes"},
{ message = "^doc*", group = "Documentation"},
{ message = "^perf*", group = "Performance"},
{ message = "^refactor*", group = "Refactor"},
{ message = "^style*", group = "Styling"},
{ message = "^test*", group = "Testing"},
{ message = "^chore\\(release\\): prepare for*", skip = true},
{ message = "^chore*", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# glob pattern for matching git tags
# tag_pattern = "v?[0-9]*"
# regex for skipping tags
# skip_tags = "v0.1.0-beta.1"
miette-7.4.0/clippy.toml 0000644 0000000 0000000 00000000020 10461020230 0013310 0 ustar 0000000 0000000 msrv = "1.70.0"
miette-7.4.0/examples/serde_json.rs 0000644 0000000 0000000 00000002460 10461020230 0015444 0 ustar 0000000 0000000 //! This example shows how to integrate miette with serde_json
//! so the decoding source will be annotated with the decoding error,
//! providing contextual information about the error.
use miette::{IntoDiagnostic, SourceOffset};
use serde_json::{self, json};
#[derive(Debug, serde::Deserialize)]
struct Library {
#[allow(unused)]
name: String,
}
#[derive(Debug, thiserror::Error, miette::Diagnostic)]
#[error("malformed json provided")]
struct SerdeError {
cause: serde_json::Error,
#[source_code]
input: String,
#[label("{cause}")]
location: SourceOffset,
}
impl SerdeError {
/// Takes the input and the `serde_json::Error` and returns a SerdeError
/// that can be rendered nicely with miette.
pub fn from_serde_error(input: impl Into, cause: serde_json::Error) -> Self {
let input = input.into();
let location = SourceOffset::from_location(&input, cause.line(), cause.column());
Self {
cause,
input,
location,
}
}
}
fn main() -> miette::Result<()> {
let input = serde_json::to_string_pretty(&json!({
"name": 123
}))
.into_diagnostic()?;
let _library: Library =
serde_json::from_str(&input).map_err(|cause| SerdeError::from_serde_error(input, cause))?;
Ok(())
}
miette-7.4.0/rustfmt.toml 0000644 0000000 0000000 00000000021 10461020230 0013515 0 ustar 0000000 0000000 edition = "2021"
miette-7.4.0/src/chain.rs 0000644 0000000 0000000 00000005466 10461020230 0013355 0 ustar 0000000 0000000 /*!
Iterate over error `.source()` chains.
NOTE: This module is taken wholesale from .
*/
use std::error::Error as StdError;
use std::vec;
use ChainState::*;
/// Iterator of a chain of source errors.
///
/// This type is the iterator returned by [`Report::chain`].
///
/// # Example
///
/// ```
/// use miette::Report;
/// use std::io;
///
/// pub fn underlying_io_error_kind(error: &Report) -> Option {
/// for cause in error.chain() {
/// if let Some(io_error) = cause.downcast_ref::() {
/// return Some(io_error.kind());
/// }
/// }
/// None
/// }
/// ```
#[derive(Clone)]
#[allow(missing_debug_implementations)]
pub struct Chain<'a> {
state: crate::chain::ChainState<'a>,
}
#[derive(Clone)]
pub(crate) enum ChainState<'a> {
Linked {
next: Option<&'a (dyn StdError + 'static)>,
},
Buffered {
rest: vec::IntoIter<&'a (dyn StdError + 'static)>,
},
}
impl<'a> Chain<'a> {
#[cold]
pub(crate) fn new(head: &'a (dyn StdError + 'static)) -> Self {
Chain {
state: ChainState::Linked { next: Some(head) },
}
}
}
impl<'a> Iterator for Chain<'a> {
type Item = &'a (dyn StdError + 'static);
fn next(&mut self) -> Option {
match &mut self.state {
Linked { next } => {
let error = (*next)?;
*next = error.source();
Some(error)
}
Buffered { rest } => rest.next(),
}
}
fn size_hint(&self) -> (usize, Option) {
let len = self.len();
(len, Some(len))
}
}
impl DoubleEndedIterator for Chain<'_> {
fn next_back(&mut self) -> Option {
match &mut self.state {
Linked { mut next } => {
let mut rest = Vec::new();
while let Some(cause) = next {
next = cause.source();
rest.push(cause);
}
let mut rest = rest.into_iter();
let last = rest.next_back();
self.state = Buffered { rest };
last
}
Buffered { rest } => rest.next_back(),
}
}
}
impl ExactSizeIterator for Chain<'_> {
fn len(&self) -> usize {
match &self.state {
Linked { mut next } => {
let mut len = 0;
while let Some(cause) = next {
next = cause.source();
len += 1;
}
len
}
Buffered { rest } => rest.len(),
}
}
}
impl Default for Chain<'_> {
fn default() -> Self {
Chain {
state: ChainState::Buffered {
rest: Vec::new().into_iter(),
},
}
}
}
miette-7.4.0/src/diagnostic_chain.rs 0000644 0000000 0000000 00000004551 10461020230 0015553 0 ustar 0000000 0000000 /*!
Iterate over error `.diagnostic_source()` chains.
*/
use crate::protocol::Diagnostic;
/// Iterator of a chain of cause errors.
#[derive(Clone, Default)]
#[allow(missing_debug_implementations)]
pub(crate) struct DiagnosticChain<'a> {
state: Option>,
}
impl<'a> DiagnosticChain<'a> {
pub(crate) fn from_diagnostic(head: &'a dyn Diagnostic) -> Self {
DiagnosticChain {
state: Some(ErrorKind::Diagnostic(head)),
}
}
pub(crate) fn from_stderror(head: &'a (dyn std::error::Error + 'static)) -> Self {
DiagnosticChain {
state: Some(ErrorKind::StdError(head)),
}
}
}
impl<'a> Iterator for DiagnosticChain<'a> {
type Item = ErrorKind<'a>;
fn next(&mut self) -> Option {
if let Some(err) = self.state.take() {
self.state = err.get_nested();
Some(err)
} else {
None
}
}
fn size_hint(&self) -> (usize, Option) {
let len = self.len();
(len, Some(len))
}
}
impl ExactSizeIterator for DiagnosticChain<'_> {
fn len(&self) -> usize {
fn depth(d: Option<&ErrorKind<'_>>) -> usize {
match d {
Some(d) => 1 + depth(d.get_nested().as_ref()),
None => 0,
}
}
depth(self.state.as_ref())
}
}
#[derive(Clone)]
pub(crate) enum ErrorKind<'a> {
Diagnostic(&'a dyn Diagnostic),
StdError(&'a (dyn std::error::Error + 'static)),
}
impl<'a> ErrorKind<'a> {
fn get_nested(&self) -> Option> {
match self {
ErrorKind::Diagnostic(d) => d
.diagnostic_source()
.map(ErrorKind::Diagnostic)
.or_else(|| d.source().map(ErrorKind::StdError)),
ErrorKind::StdError(e) => e.source().map(ErrorKind::StdError),
}
}
}
impl<'a> std::fmt::Debug for ErrorKind<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrorKind::Diagnostic(d) => d.fmt(f),
ErrorKind::StdError(e) => e.fmt(f),
}
}
}
impl<'a> std::fmt::Display for ErrorKind<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ErrorKind::Diagnostic(d) => d.fmt(f),
ErrorKind::StdError(e) => e.fmt(f),
}
}
}
miette-7.4.0/src/diagnostic_impls.rs 0000644 0000000 0000000 00000002374 10461020230 0015616 0 ustar 0000000 0000000 /*!
Default trait implementations for [`Diagnostic`].
*/
use std::{convert::Infallible, fmt::Display};
use crate::{Diagnostic, LabeledSpan, Severity, SourceCode};
impl Diagnostic for Infallible {
fn code<'a>(&'a self) -> Option> {
match *self {}
}
fn severity(&self) -> Option {
match *self {}
}
fn help<'a>(&'a self) -> Option> {
match *self {}
}
fn url<'a>(&'a self) -> Option> {
match *self {}
}
fn source_code(&self) -> Option<&dyn SourceCode> {
match *self {}
}
fn labels(&self) -> Option + '_>> {
match *self {}
}
fn related<'a>(&'a self) -> Option + 'a>> {
match *self {}
}
fn diagnostic_source(&self) -> Option<&dyn Diagnostic> {
match *self {}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::Report;
/// Test that [`Infallible`] implements [`Diagnostic`] by seeing if a function that's generic over `Diagnostic`
/// will accept `Infallible` as a type parameter.
#[test]
fn infallible() {
let _ = Report::new::;
}
}
miette-7.4.0/src/error.rs 0000644 0000000 0000000 00000003200 10461020230 0013404 0 ustar 0000000 0000000 use std::{fmt, io};
use thiserror::Error;
use crate::Diagnostic;
/**
Error enum for miette. Used by certain operations in the protocol.
*/
#[derive(Debug, Error)]
pub enum MietteError {
/// Wrapper around [`std::io::Error`]. This is returned when something went
/// wrong while reading a [`SourceCode`](crate::SourceCode).
#[error(transparent)]
IoError(#[from] io::Error),
/// Returned when a [`SourceSpan`](crate::SourceSpan) extends beyond the
/// bounds of a given [`SourceCode`](crate::SourceCode).
#[error("The given offset is outside the bounds of its Source")]
OutOfBounds,
}
impl Diagnostic for MietteError {
fn code<'a>(&'a self) -> Option> {
match self {
MietteError::IoError(_) => Some(Box::new("miette::io_error")),
MietteError::OutOfBounds => Some(Box::new("miette::span_out_of_bounds")),
}
}
fn help<'a>(&'a self) -> Option> {
match self {
MietteError::IoError(_) => None,
MietteError::OutOfBounds => Some(Box::new(
"Double-check your spans. Do you have an off-by-one error?",
)),
}
}
fn url<'a>(&'a self) -> Option> {
let crate_version = env!("CARGO_PKG_VERSION");
let variant = match self {
MietteError::IoError(_) => "#variant.IoError",
MietteError::OutOfBounds => "#variant.OutOfBounds",
};
Some(Box::new(format!(
"https://docs.rs/miette/{}/miette/enum.MietteError.html{}",
crate_version, variant,
)))
}
}
miette-7.4.0/src/eyreish/context.rs 0000644 0000000 0000000 00000013734 10461020230 0015424 0 ustar 0000000 0000000 use super::error::{ContextError, ErrorImpl};
use super::{Report, WrapErr};
use core::fmt::{self, Debug, Display, Write};
use std::error::Error as StdError;
use crate::{Diagnostic, LabeledSpan};
mod ext {
use super::*;
pub trait Diag {
#[cfg_attr(track_caller, track_caller)]
fn ext_report(self, msg: D) -> Report
where
D: Display + Send + Sync + 'static;
}
impl Diag for E
where
E: Diagnostic + Send + Sync + 'static,
{
fn ext_report(self, msg: D) -> Report
where
D: Display + Send + Sync + 'static,
{
Report::from_msg(msg, self)
}
}
impl Diag for Report {
fn ext_report(self, msg: D) -> Report
where
D: Display + Send + Sync + 'static,
{
self.wrap_err(msg)
}
}
}
impl WrapErr for Option {
fn wrap_err(self, msg: D) -> Result
where
D: Display + Send + Sync + 'static,
{
match self {
Some(t) => Ok(t),
None => Err(Report::from(crate::eyreish::wrapper::DisplayError(msg))),
}
}
fn wrap_err_with(self, msg: F) -> Result
where
D: Display + Send + Sync + 'static,
F: FnOnce() -> D,
{
match self {
Some(t) => Ok(t),
None => Err(Report::from(crate::eyreish::wrapper::DisplayError(msg()))),
}
}
fn context(self, msg: D) -> Result
where
D: Display + Send + Sync + 'static,
{
self.wrap_err(msg)
}
fn with_context(self, msg: F) -> Result
where
D: Display + Send + Sync + 'static,
F: FnOnce() -> D,
{
self.wrap_err_with(msg)
}
}
impl WrapErr for Result
where
E: ext::Diag + Send + Sync + 'static,
{
fn wrap_err(self, msg: D) -> Result
where
D: Display + Send + Sync + 'static,
{
match self {
Ok(t) => Ok(t),
Err(e) => Err(e.ext_report(msg)),
}
}
fn wrap_err_with(self, msg: F) -> Result
where
D: Display + Send + Sync + 'static,
F: FnOnce() -> D,
{
match self {
Ok(t) => Ok(t),
Err(e) => Err(e.ext_report(msg())),
}
}
fn context(self, msg: D) -> Result
where
D: Display + Send + Sync + 'static,
{
self.wrap_err(msg)
}
fn with_context(self, msg: F) -> Result
where
D: Display + Send + Sync + 'static,
F: FnOnce() -> D,
{
self.wrap_err_with(msg)
}
}
impl Debug for ContextError
where
D: Display,
E: Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Error")
.field("msg", &Quoted(&self.msg))
.field("source", &self.error)
.finish()
}
}
impl Display for ContextError
where
D: Display,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&self.msg, f)
}
}
impl StdError for ContextError
where
D: Display,
E: StdError + 'static,
{
fn source(&self) -> Option<&(dyn StdError + 'static)> {
Some(&self.error)
}
}
impl StdError for ContextError
where
D: Display,
{
fn source(&self) -> Option<&(dyn StdError + 'static)> {
unsafe { Some(ErrorImpl::error(self.error.inner.by_ref())) }
}
}
impl Diagnostic for ContextError
where
D: Display,
E: Diagnostic + 'static,
{
fn code<'a>(&'a self) -> Option> {
self.error.code()
}
fn severity(&self) -> Option {
self.error.severity()
}
fn help<'a>(&'a self) -> Option> {
self.error.help()
}
fn url<'a>(&'a self) -> Option> {
self.error.url()
}
fn labels<'a>(&'a self) -> Option + 'a>> {
self.error.labels()
}
fn source_code(&self) -> Option<&dyn crate::SourceCode> {
self.error.source_code()
}
fn related<'a>(&'a self) -> Option + 'a>> {
self.error.related()
}
}
impl Diagnostic for ContextError
where
D: Display,
{
fn code<'a>(&'a self) -> Option> {
unsafe { ErrorImpl::diagnostic(self.error.inner.by_ref()).code() }
}
fn severity(&self) -> Option {
unsafe { ErrorImpl::diagnostic(self.error.inner.by_ref()).severity() }
}
fn help<'a>(&'a self) -> Option> {
unsafe { ErrorImpl::diagnostic(self.error.inner.by_ref()).help() }
}
fn url<'a>(&'a self) -> Option> {
unsafe { ErrorImpl::diagnostic(self.error.inner.by_ref()).url() }
}
fn labels<'a>(&'a self) -> Option + 'a>> {
unsafe { ErrorImpl::diagnostic(self.error.inner.by_ref()).labels() }
}
fn source_code(&self) -> Option<&dyn crate::SourceCode> {
self.error.source_code()
}
fn related<'a>(&'a self) -> Option + 'a>> {
self.error.related()
}
}
struct Quoted(D);
impl Debug for Quoted
where
D: Display,
{
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_char('"')?;
Quoted(&mut *formatter).write_fmt(format_args!("{}", self.0))?;
formatter.write_char('"')?;
Ok(())
}
}
impl Write for Quoted<&mut fmt::Formatter<'_>> {
fn write_str(&mut self, s: &str) -> fmt::Result {
Display::fmt(&s.escape_debug(), self.0)
}
}
pub(crate) mod private {
use super::*;
pub trait Sealed {}
impl Sealed for Result where E: ext::Diag {}
impl Sealed for Option {}
}
miette-7.4.0/src/eyreish/error.rs 0000644 0000000 0000000 00000066032 10461020230 0015070 0 ustar 0000000 0000000 use core::any::TypeId;
use core::fmt::{self, Debug, Display};
use core::mem::ManuallyDrop;
use core::ptr::{self, NonNull};
use std::error::Error as StdError;
use super::ptr::{Mut, Own, Ref};
use super::Report;
use super::ReportHandler;
use crate::chain::Chain;
use crate::eyreish::wrapper::WithSourceCode;
use crate::{Diagnostic, SourceCode};
use core::ops::{Deref, DerefMut};
impl Report {
/// Create a new error object from any error type.
///
/// The error type must be thread safe and `'static`, so that the `Report`
/// will be as well.
///
/// If the error type does not provide a backtrace, a backtrace will be
/// created here to ensure that a backtrace exists.
#[cfg_attr(track_caller, track_caller)]
#[cold]
pub fn new(error: E) -> Self
where
E: Diagnostic + Send + Sync + 'static,
{
Report::from_std(error)
}
/// Create a new error object from a printable error message.
///
/// If the argument implements [`std::error::Error`], prefer `Report::new`
/// instead which preserves the underlying error's cause chain and
/// backtrace. If the argument may or may not implement [`std::error::Error`]
/// now or in the future, use `miette!(err)` which handles either way
/// correctly.
///
/// `Report::msg("...")` is equivalent to `miette!("...")` but occasionally
/// convenient in places where a function is preferable over a macro, such
/// as iterator or stream combinators:
///
/// ```
/// # mod ffi {
/// # pub struct Input;
/// # pub struct Output;
/// # pub async fn do_some_work(_: Input) -> Result