585 Commits

Author SHA1 Message Date
Pavan Kumar Sunkara
be43daec57
Merge branch 'master' into bump-owo-colors-for-everyone 2024-04-25 22:52:33 +01:00
DaniPopes
1369e09fb2
Don't evaluate 1-argument ensure! condition twice (#166)
`ensure!($cond:expr)` currently expands to two nested `if !$cond {}`.

Co-authored-by: Jane Losare-Lusby <jlusby@yaah.dev>
2024-04-25 22:52:12 +01:00
nori li
5aea38b51c
Merge branch 'master' into bump-owo-colors-for-everyone 2024-04-25 14:47:32 -07:00
LeoniePhiline
586e359220
fix(docs): enclose inline code in backticks (#170)
Fixes #169

Besides enclosing inline code in backticks, I also made two tiny
documentation improvements - please let me know if you want them undone:

- In the `Report::msg` docs, the user is referred to `Report::new`. I
changed this from plain inline code into a link.
- I expanded _"`Display` impl"_ to _"`Display` implementation"_, since
`impl` is a Rust token, but
  - _"`Display` `impl`"_ looked silly, and 
  - _"`impl Display`"_ disturbed the flow of reading.

Co-authored-by: Jane Losare-Lusby <jlusby@yaah.dev>
2024-04-25 14:36:46 -07:00
Jubilee Young
b65fb592de Pin trybuild to maintain MSRV
Also, check in our lockfile, due to Cargo's change in guidance for libs.
2024-04-25 14:27:36 -07:00
Jubilee Young
6e2ffcc0c2 Bump workspace to owo-colors 4.0
Requires adding a path dependency in color-eyre on color-spantrace
so that the versions agree. Fortunately we can do that now!
2024-04-25 14:26:24 -07:00
nori li
b0c3e3ff9c
Add a gitattributes file to specify LF line endings (#126)
Since almost all files not on our gitignore are text files, it uses `*
text` as a catch-all and specifies *.png as binary.

Co-authored-by: Jane Losare-Lusby <jlusby@yaah.dev>
2024-04-25 14:24:21 -07:00
Freja Roberts
41699aa483
Fix ci breaking due to new dependencies and rustc changes (backport to master) (#163)
Applies the same fixes that was applied to `color-eyre-0.6` to master,
namely the new update to `trybuild` that breaks our MSRV requirement,
requiring us to pin the version, as the dependency only bumped the patch
version for the updated MRSV.

It also fixes the theme test breaking on windows due to new
*before-main* machinery on windows affecting the backtrace. This is
fixed by filtering out the functions before and including main(due to no
take_until iter adapter in std), but still includes the panicking
function call.

There are currently three branches that need/needed this fix

- master: containing latest breaking code for 1.0
- color-eyre-0.6
- release-0.6 (does not include the theme test change as color-eyre is
not present there)
2024-04-25 14:18:20 -07:00
Freja Roberts
7a5c32acd7
Add color-eyre to workspace (#110) 2024-03-14 22:36:59 +01:00
Freja Roberts
eb8d059c50 Merge remote-tracking branch 'origin/master' into color-eyre 2024-03-14 18:05:00 +01:00
LeoniePhiline
75beaaea3f
fix: remove anyhow feature flag from OptionExt location test (#148)
# 1. Clarify trait usage in location test


[`8522f02`](8522f02518)

Both `WrapErr` and `ContextCompat` expose `anyhow` compatibility
methods.

- `ContextCompat` is completely feature gated behind the `anyhow` flag.

- `WrapErr`, on the other hand, feature-gates individual functions
behind the `anyhow` flag.

This has led to [confusion][confusion] in the past.

This change moves the `use eyre::WrapErr` statement from the top of the
module into each individual test, as [identically named
functions](https://github.com/eyre-rs/eyre/issues/149) (`wrap_err.*`)
are exposed both by `WrapErr` and `ContextCompat`.

With `use eyre::WrapErr` moved directly into the tests, it becomes clear
which trait-provided `fn` is being called.

[confusion]:
https://github.com/eyre-rs/eyre/pull/138#discussion_r1432909562

# 2. Remove `anyhow` feature flag from `OptionExt` location test 


[`68744f1`](68744f19fb)

This bug was introduced (by me) in
34bd1d9893 (diff-1ff47dac6cf55e34ff587968c5b1f1ec6b6ae39d2668a66ecba3633163a21fc5R86)
- partly due to the confusion fixed with the above commit.

Fixes https://github.com/eyre-rs/eyre/issues/147
2024-03-14 18:01:32 +01:00
Jubilee
e570151950
color-spantrace: bump owo-colors to 4.0 (#156) 2024-02-15 21:41:55 +00:00
Freja Roberts
cb4bab6fd0 chore: update issues redirect 2024-01-29 14:54:22 +01:00
Freja Roberts
8ebc308a0a fix: make theme test more lenient
The test now only considers our part of the backtrace, allowing for
changes in rust std library to not break the test
2024-01-29 14:54:20 +01:00
Freja Roberts
eb26e0202f fix: color-eyre theme test suite backtraces to match the tested MSRV 2024-01-23 11:51:43 +01:00
Freja Roberts
1da23d9081
Merge branch 'master' into color-eyre 2024-01-23 10:23:48 +01:00
LeoniePhiline
34bd1d9893
feat: introduce an "anyhow" compatibility layer feature flag (#138)
This change hides the `anyhow` compatibility layer behind an `"anyhow"`
feature flag.
In `eyre` v1.0.0 the feature is currently enabled by default.

Fixes #131

---------

Co-authored-by: Freja Roberts <ten3roberts@gmail.com>
2024-01-16 17:10:12 +01:00
Freja Roberts
d6c0b8d8a3
Bump version 1.0.0 (#146)
Prepares for a stable `1.0.0` release.

This release would signify the start of a stability commitment, and
allow us to update APIs to be reflictive or the current state and things
which we have learnt since.

@yaahc, I would like to request your signoff on this :)
2024-01-16 16:40:22 +01:00
LeoniePhiline
32826ab95e
fix(docs): fix two rustdoc::bare_urls warnings (#139)
Fixes #137
2023-12-30 01:50:02 +00:00
Jane Losare-Lusby
9caee14e36
Release 0.6.11 (#134)
rereleasing https://github.com/eyre-rs/eyre/pull/132 minus one breaking
change
2023-12-30 01:41:55 +00:00
Freja Roberts
53ec78d8c0
fix: ok_or_eyre not using track_caller (#140)
`ok_or_eyre` did not use `track_caller`, which meant the error location
was incorrect compared to the equivalent anyhow::context feature
2023-12-29 17:37:14 -08:00
Freja Roberts
770ac3fa14
Fix invalid drop impl call in Report::downcast (#143)
The context chain downcast called converted to the wrong inner type
which caused the wrong drop impl to be called.

The tests did not catch this because they had compatible drop
implementations due to matching type layout. Solved by swizzling the
fields of the chain test types to force incompatible layouts

Resolves: #141
2023-12-29 17:32:31 -08:00
Jane Losare-Lusby
32d84dcbac
Revert "Automatically convert to external errors w/ ensure! and bail!" (#133)
Reverts eyre-rs/eyre#95
2023-12-13 13:37:26 -08:00
Freja Roberts
de636faf96 fix: clippy 2023-12-11 14:38:33 +01:00
Freja Roberts
e61cf4eb3c fix: miri tests 2023-12-11 14:37:24 +01:00
Freja Roberts
e3fd62079a Merge commit '4a5297d30b0f0754a3bbc47b71bb55b04960c0ad' into color-eyre 2023-12-11 14:05:40 +01:00
Freja Roberts
57216d0b14 Merge remote-tracking branch 'origin/master' into color-eyre 2023-12-08 16:56:40 +01:00
Freja Roberts
d825b49a11 fix: conflicting example binaries 2023-12-08 16:53:14 +01:00
nori li
d5cad7c2a1
Release 0.6.10 (#132)
Updates changelog and version references for release 0.6.10
2023-12-07 22:47:27 -08:00
LeoniePhiline
4e1f323d31
Extend Option with ok_or_eyre (#129)
Previously, a closure and macro invocation was
required to generate a static string error object
from an `Option::None`.

This change adds an extension trait, providing
the `ok_or_eyre` method on the `Option` type.

`Option::ok_or_eyre` accepts static error messages
and creates `Report` objects lazily in the `None` case.

Implements #125
2023-12-06 18:01:55 +01:00
Kyle Lacy
da84e8c624
Add eyre::Ok (#91)
This change introduces the function eyre::Ok(), a backport of the convenience function anyhow::Ok() which avoids a lengthy turbofish when producing an Ok(()).
2023-11-25 20:49:47 -08:00
James Baker
a795c97a2b
Automatically convert to external errors w/ ensure! and bail! (#95)
* Automatically convert to external errors

A pattern documented by thiserror is

```
pub enum MyError {
  ...

  #[error(transparent)]
  Other(#[from] anyhow::Error), // source and Display delegate to anyhow::Error
}
```

It'd be nice for this to work with ensure! but right now, that macro returns
an eyre error.

With this PR, the macro additionally runs an .into(). In the case that
the return type is an eyre error, obviously .into() will do nothing and
be compiled away. In the case that there is a from method, the wrapping
will occur. This enables eyre to be used for ergonomic 'implementation
detail error' in a thiserror using system which has contractual errors.

Since this conversion adds more flexibility to the result of these
macros, this could break code which relies on the narrowness to inform
type inference. If this is the case, update your code to specify the
result type you would like to use.

* Fix single-argument ensure test and allow dead code.

By adding the possibility for polymorphism from an eyre error, the
previous commit breaks a previous eyre test for single-argument
ensure!().

This change fixes that test and adds `allow(dead_code)` to the struct
used for the test for automatically converting to external errors.

---------

Co-authored-by: nori li <50680474+thenorili@users.noreply.github.com>
2023-11-24 22:04:47 -08:00
Akshay Narayan
0979ad7718
Add documentation on wrap_err vs wrap_err_with (#93)
Adds documentation on the difference in performance characteristics between  wrap_err vs wrap_err_with explored in Issue #126

---------

Co-authored-by: Jane Losare-Lusby <jlusby@yaah.dev>
2023-11-24 22:21:05 +00:00
Georg Brandl
ef778006cc macros: fix references to Error in docstrings 2023-11-22 01:45:31 -05:00
sharnoff
ec98ce3665 Add 1-argument ensure!($expr) 2023-11-21 14:34:49 -08:00
Jane Losare-Lusby
949e845777 remove deprecated lints as of 1.74 2023-11-21 14:28:07 -08:00
Jane Losare-Lusby
6d2e6e8df2 Release independent packages
color-spantrace@0.2.1
eyre@0.6.9

Generated by cargo-workspaces
2023-11-21 14:28:07 -08:00
Jane Losare-Lusby
a1c5dad686 manually apply cargo-release substitutions and also prep color-spantrace for publish 2023-11-21 14:28:07 -08:00
Jane Losare-Lusby
c31b47a530 Update changelog for 0.6.9 release 2023-11-21 14:28:07 -08:00
nori li
75511afd0e
Remove obsolete private_in_public lint in nightly and beta. (#113)
RFC 2145 is in beta now, deprecating the public_in_private lint.
https://rust-lang.github.io/rfcs/2145-type-privacy.html

public_in_private has been superceded by three new lints. The first two
are warn-by-default and the third is allow-by-default. See the excerpt
below for some details.

This change skips this lint in nightly and beta in favor of the new
warn-by-default lints.

This change revealed a bug in the toolchain config option for
color-spantrace -- it doesn't exist! The lint it was guarding was never
turned on. This adds a minimal build script to check for toolchain to
color-spantrace. Its functionality is tested in the eyre crate, which
seems sufficient to me.

After this change there are only two more build warnings for eyre and
color-spantrace, the future-incompat dependency warning and the more
serious filename collision.

<quote>
    Lint private_interfaces is reported when a type with visibility x is
    used in primary interface of an item with effective visibility y and
    x < y. This lint is warn-by-default.

    Lint private_bounds is reported when a type or trait with visibility
    x is used in secondary interface of an item with effective
    visibility y and x < y. This lint is warn-by-default.

    Lint unnameable_types is reported when effective visibility of a
    type is larger than module in which it can be named, either
    directly, or through reexports, or through trivial type aliases
    (type X = Y;, no generics on both sides). This lint is
    allow-by-default.

    Compatibility lint private_in_public is never reported and removed.
</quote>
2023-11-17 09:29:52 -08:00
Pavan Kumar Sunkara
4a5297d30b
Merge pull request #140 from eyre-rs/fix-ci
Fix tests and warnings from new compiler versions
2023-11-10 11:11:45 +00:00
Pavan Kumar Sunkara
fc4f006ba8
Merge pull request #117 from thenorili/pyo3-future-incompat
Update future-incompat pyo3 dependency
2023-11-10 10:55:46 +00:00
nori li
cadf826aba Update future-incompat pyo3 dependency
pyo3 v0.13.2 is tripping future-incompat. This change updates it to the newest 0.20.

pyo3 v0.16.0 renamed pvalue -> value.

The other future-incompat dependency, nom, is an indirect dependency through ansi-parser.

See issue 116
2023-11-10 10:52:24 +00:00
Pavan Kumar Sunkara
2422bcd089
Merge pull request #118 from thenorili/filename-collision
Avoid filename collision in the monorepo structure
2023-11-10 10:50:55 +00:00
nori li
1fc5c56683
Avoid filename collision in the monorepo structure
Warning: output filename collision appears in both stable and nightly builds.

It's slightly more impactful than just a warning. Running cargo +nightly
test, cargo test, cargo +nightly test in windows produces a linker error
where color-spantrace tries to use eyre's usage.exe, see error 2 below.
It's worked around pretty easily with cargo clean, but it's a problem
that might get worse as the monorepo effort expands!

This patch renames `usage.rs` to `CRATENAME-usage.rs`.

Issue #115
2023-11-09 22:31:42 -08:00
Tei Roberts
b4a26d7670 fix: spantrace test 2023-11-08 00:35:32 +01:00
Tei Roberts
7fadb08f08 fix: track caller test 2023-11-08 00:32:34 +01:00
Tei Roberts
2629d614a8 fix: no-default-features test 2023-11-08 00:29:49 +01:00
Tei Roberts
eedde5137f fix: test_error_backwards_compatability 2023-11-08 00:17:36 +01:00
Tei Roberts
a504a60968 fix: warnings for newer rust versions 2023-11-07 23:43:05 +01:00