David Tolnay
61ad446799
Document the interaction of context and downcast
2019-10-27 21:33:58 -07:00
David Tolnay
b9d69af29e
Add tests for downcasting context
2019-10-27 21:33:57 -07:00
David Tolnay
b119f4997f
Remove unneeded object_is vtable method
2019-10-27 21:33:57 -07:00
David Tolnay
fa36bac5b5
Rename the ErrorImpl tail to _object
...
Avoids _error.error repetition when manipulation ErrorImpl<ContextError>,
and works well with object_ref / object_mut naming in the vtable.
2019-10-27 21:33:57 -07:00
David Tolnay
6a25ac3692
Support downcasting ContextError<C, Error> to C and cause
2019-10-27 21:33:57 -07:00
David Tolnay
d84def42ce
Support downcasting ContextError<C, E> to C and E
2019-10-27 21:33:57 -07:00
David Tolnay
5d1e685152
Move downcasting into vtable
2019-10-27 21:21:01 -07:00
David Tolnay
5e04e776ef
Disable needless_doctest_main lint
2019-10-27 21:20:38 -07:00
David Tolnay
b2f0f456f5
Atomic flag type for use in Drop tests
2019-10-27 21:20:03 -07:00
David Tolnay
e674ddcf79
Put context first in the Debug impl for ContextError
2019-10-27 16:40:28 -07:00
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