630 Commits

Author SHA1 Message Date
David Tolnay
45e6fc6bfd
Expand ContextError vtable to prepare for extending downcast support 2019-10-27 16:16:56 -07:00
David Tolnay
b261a64e48
Specify types where the manual vtable relies on them 2019-10-27 16:07:30 -07:00
David Tolnay
a2846fd345
Eliminate backtrace_if_absent in Error::context
This avoids stepping through the list of causes when adding context to
the anyhow::Error type which is known to already hold a backtrace.

Reduces the release-mode time of the following loop from 4 seconds to 4
milliseconds.

    let mut err = anyhow!("...");
    for _ in 0..25000 {
        err = err.context("...");
    }
2019-10-27 16:06:48 -07:00
David Tolnay
8885e93ca6
Merge pull request #33 from dtolnay/typeid
Move TypeId out of the Box allocation
2019-10-27 15:32:28 -07:00
David Tolnay
7b9b07ea8a
Add test of unsuccessful downcasts 2019-10-27 15:26:35 -07:00
David Tolnay
4ec3791086
Move TypeId out of the Box allocation 2019-10-27 15:24:22 -07:00
David Tolnay
30c2eab25f
Move ContextError to error.rs in preparation for refactor 2019-10-27 15:00:04 -07:00
David Tolnay
9f38495af3
Swap ContextError type parameters to match type name 2019-10-27 14:56:45 -07:00
David Tolnay
def64cbb96 Match actual capitalization in Context example output 2019-10-21 19:51:17 -07:00
David Tolnay
810f73e42c
Release 1.0.17 2019-10-21 11:25:23 -07:00
David Tolnay
7ce0a30710
Move macros to their own module
Now that lib.rs needs to have other things in it.
2019-10-21 11:24:58 -07:00
David Tolnay
27fcdd42a0
Also move Error and Chain to get usable paths in diagnostics 2019-10-21 11:24:58 -07:00
David Tolnay
fc44da4836
Merge pull request #31 from dtolnay/diagnostic
Work around bad diagnostic when missing Context import
2019-10-21 13:24:49 -05:00
David Tolnay
cf77cabcb4
Work around bad diagnostic when missing Context import
Previously the compiler would say:

    error[E0599]: no method named `context` found for type `std::result::Result<(), anyhow::error::Error>` in the current scope
      --> src/main.rs:83:13
       |
    83 |             context(...)?;
       |             ^^^^^^^ method not found in `std::result::Result<(), anyhow::error::Error>`
       |
       = help: items from traits can only be used if the trait is in scope
    help: the following trait is implemented but not in scope; perhaps add a `use` for it:
       |
    19 | use anyhow::context::Context;

where the `anyhow::context::Context` in the suggestion is not a path
that is accessible to the user.
2019-10-21 11:14:40 -07:00
David Tolnay
2a5257aa8a
Release 1.0.16 2019-10-19 17:48:24 -04:00
David Tolnay
68225d2d85
Merge pull request #28 from dtolnay/from
Add From<anyhow::Error> for Box<dyn std::error::Error>
2019-10-19 17:48:16 -04:00
David Tolnay
b961f3a594
Add From<anyhow::Error> for Box<dyn std::error::Error> 2019-10-19 17:44:32 -04:00
David Tolnay
3570a5ec2c
Release 1.0.15 2019-10-19 09:13:32 -04:00
David Tolnay
5038225dd2
Merge pull request #27 from dtolnay/result
Show example of anyhow::Result with two type parameters
2019-10-19 09:12:42 -04:00
David Tolnay
f7c0e7dbf9
Show example of anyhow::Result with two type parameters 2019-10-19 09:07:52 -04:00
David Tolnay
20fbcf3168
Release 1.0.14 2019-10-18 11:19:45 -04:00
David Tolnay
2191a63258
Merge pull request #24 from dtolnay/probe
Replace version check with probing Backtrace api
2019-10-18 11:08:49 -04:00
David Tolnay
6d0a0196eb
Add test that backtrace method exists on nightly 2019-10-18 10:50:31 -04:00
David Tolnay
5ada2978c5
Replace version check with probing Backtrace api 2019-10-18 10:45:15 -04:00
David Tolnay
d7c37d6c4d
Release 1.0.13 2019-10-13 09:08:18 -07:00
David Tolnay
7a7d683f55
Merge pull request #21 from dtolnay/build
Detect compiler minor version in build script
2019-10-13 09:08:12 -07:00
David Tolnay
d782e42503
Detect compiler minor version in build script 2019-10-13 09:03:20 -07:00
David Tolnay
f432c46269
Release 1.0.12 2019-10-11 18:32:13 -07:00
David Tolnay
499e265ce3
Merge pull request #19 from dtolnay/infer
Consolidate to one Context impl for Result to improve inference
2019-10-11 18:31:53 -07:00
David Tolnay
c695e63286
Consolidate to one Context impl for Result to improve inference 2019-10-11 18:27:03 -07:00
David Tolnay
6057864f8b
Add test demonstrating context inference failure 2019-10-11 18:23:56 -07:00
David Tolnay
f9ca23f8ed Release 1.0.11 2019-10-09 18:46:36 -07:00
David Tolnay
a727067a7d Format with rustfmt 2019-09-08 2019-10-09 18:45:40 -07:00
David Tolnay
4118197eac Explicitly specify all cast types in unsafe code 2019-10-09 18:45:40 -07:00
David Tolnay
d57f80c822 Rename vtable object ref and mut methods that are no longer raw ptr 2019-10-09 18:42:25 -07:00
David Tolnay
eeaf2efc35
Merge pull request #16 from johnschug/master
Fix UB when accessing errors with large alignment
2019-10-09 18:41:18 -07:00
John Schug
8ebf822c95 Fix UB when accessing errors with large alignment 2019-10-09 17:46:09 -07:00
David Tolnay
db8fa67c12
Release 1.0.10 2019-10-09 11:14:28 -07:00
David Tolnay
a37dea2133
Pull in thiserror library for tests 2019-10-09 11:14:00 -07:00
David Tolnay
d4bc68cf65
Link to thiserror instead of err-derive 2019-10-09 11:11:03 -07:00
David Tolnay
4a47e1362f
Release 1.0.9 2019-10-08 23:10:34 -07:00
David Tolnay
96eee9b062
Ignore some Clippy lints 2019-10-08 23:10:14 -07:00
David Tolnay
1926be80f4
Seal the Context trait 2019-10-08 23:09:08 -07:00
David Tolnay
c31e708a2c
Release 1.0.8 2019-10-08 17:42:01 -07:00
David Tolnay
da60588d02
Fix anyhow_kind dispatch on owned value 2019-10-08 17:41:25 -07:00
David Tolnay
d0c25a6b1c
Release 1.0.7 2019-10-08 17:33:25 -07:00
David Tolnay
55d054427c
Add test of anyhow macro tagged dispatch 2019-10-08 17:29:24 -07:00
David Tolnay
38c8d78f09
Recognize literal anyhow as a special case 2019-10-08 17:23:14 -07:00
David Tolnay
443cc8dedb
Document tagged dispatch approach 2019-10-08 17:20:23 -07:00
David Tolnay
14bab22e06
Tagged dispatch for anyhow!($expr) 2019-10-08 17:20:10 -07:00