Initial vendor packages
Signed-off-by: Valentin Popov <valentin@popov.link>
This commit is contained in:
1
vendor/thiserror/.cargo-checksum.json
vendored
Normal file
1
vendor/thiserror/.cargo-checksum.json
vendored
Normal file
File diff suppressed because one or more lines are too long
48
vendor/thiserror/Cargo.toml
vendored
Normal file
48
vendor/thiserror/Cargo.toml
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
# 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 = "2021"
|
||||
rust-version = "1.56"
|
||||
name = "thiserror"
|
||||
version = "1.0.56"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
description = "derive(Error)"
|
||||
documentation = "https://docs.rs/thiserror"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"error",
|
||||
"error-handling",
|
||||
"derive",
|
||||
]
|
||||
categories = ["rust-patterns"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/dtolnay/thiserror"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
rustdoc-args = ["--generate-link-to-definition"]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies.thiserror-impl]
|
||||
version = "=1.0.56"
|
||||
|
||||
[dev-dependencies.anyhow]
|
||||
version = "1.0.73"
|
||||
|
||||
[dev-dependencies.ref-cast]
|
||||
version = "1.0.18"
|
||||
|
||||
[dev-dependencies.rustversion]
|
||||
version = "1.0.13"
|
||||
|
||||
[dev-dependencies.trybuild]
|
||||
version = "1.0.81"
|
||||
features = ["diff"]
|
176
vendor/thiserror/LICENSE-APACHE
vendored
Normal file
176
vendor/thiserror/LICENSE-APACHE
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
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
|
23
vendor/thiserror/LICENSE-MIT
vendored
Normal file
23
vendor/thiserror/LICENSE-MIT
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Permission is hereby granted, free of charge, to any
|
||||
person obtaining a copy of this software and associated
|
||||
documentation files (the "Software"), to deal in the
|
||||
Software without restriction, including without
|
||||
limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software
|
||||
is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice
|
||||
shall be included in all copies or substantial portions
|
||||
of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
||||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
||||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
222
vendor/thiserror/README.md
vendored
Normal file
222
vendor/thiserror/README.md
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
derive(Error)
|
||||
=============
|
||||
|
||||
[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/thiserror-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/thiserror)
|
||||
[<img alt="crates.io" src="https://img.shields.io/crates/v/thiserror.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/thiserror)
|
||||
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-thiserror-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/thiserror)
|
||||
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/dtolnay/thiserror/ci.yml?branch=master&style=for-the-badge" height="20">](https://github.com/dtolnay/thiserror/actions?query=branch%3Amaster)
|
||||
|
||||
This library provides a convenient derive macro for the standard library's
|
||||
[`std::error::Error`] trait.
|
||||
|
||||
[`std::error::Error`]: https://doc.rust-lang.org/std/error/trait.Error.html
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
thiserror = "1.0"
|
||||
```
|
||||
|
||||
*Compiler support: requires rustc 1.56+*
|
||||
|
||||
<br>
|
||||
|
||||
## Example
|
||||
|
||||
```rust
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum DataStoreError {
|
||||
#[error("data store disconnected")]
|
||||
Disconnect(#[from] io::Error),
|
||||
#[error("the data for key `{0}` is not available")]
|
||||
Redaction(String),
|
||||
#[error("invalid header (expected {expected:?}, found {found:?})")]
|
||||
InvalidHeader {
|
||||
expected: String,
|
||||
found: String,
|
||||
},
|
||||
#[error("unknown data store error")]
|
||||
Unknown,
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Details
|
||||
|
||||
- Thiserror deliberately does not appear in your public API. You get the same
|
||||
thing as if you had written an implementation of `std::error::Error` by hand,
|
||||
and switching from handwritten impls to thiserror or vice versa is not a
|
||||
breaking change.
|
||||
|
||||
- Errors may be enums, structs with named fields, tuple structs, or unit
|
||||
structs.
|
||||
|
||||
- A `Display` impl is generated for your error if you provide `#[error("...")]`
|
||||
messages on the struct or each variant of your enum, as shown above in the
|
||||
example.
|
||||
|
||||
The messages support a shorthand for interpolating fields from the error.
|
||||
|
||||
- `#[error("{var}")]` ⟶ `write!("{}", self.var)`
|
||||
- `#[error("{0}")]` ⟶ `write!("{}", self.0)`
|
||||
- `#[error("{var:?}")]` ⟶ `write!("{:?}", self.var)`
|
||||
- `#[error("{0:?}")]` ⟶ `write!("{:?}", self.0)`
|
||||
|
||||
These shorthands can be used together with any additional format args, which
|
||||
may be arbitrary expressions. For example:
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("invalid rdo_lookahead_frames {0} (expected < {})", i32::MAX)]
|
||||
InvalidLookahead(u32),
|
||||
}
|
||||
```
|
||||
|
||||
If one of the additional expression arguments needs to refer to a field of the
|
||||
struct or enum, then refer to named fields as `.var` and tuple fields as `.0`.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("first letter must be lowercase but was {:?}", first_char(.0))]
|
||||
WrongCase(String),
|
||||
#[error("invalid index {idx}, expected at least {} and at most {}", .limits.lo, .limits.hi)]
|
||||
OutOfBounds { idx: usize, limits: Limits },
|
||||
}
|
||||
```
|
||||
|
||||
- A `From` impl is generated for each variant containing a `#[from]` attribute.
|
||||
|
||||
Note that the variant must not contain any other fields beyond the source
|
||||
error and possibly a backtrace. A backtrace is captured from within the `From`
|
||||
impl if there is a field for it.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
Io {
|
||||
#[from]
|
||||
source: io::Error,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
- The Error trait's `source()` method is implemented to return whichever field
|
||||
has a `#[source]` attribute or is named `source`, if any. This is for
|
||||
identifying the underlying lower level error that caused your error.
|
||||
|
||||
The `#[from]` attribute always implies that the same field is `#[source]`, so
|
||||
you don't ever need to specify both attributes.
|
||||
|
||||
Any error type that implements `std::error::Error` or dereferences to `dyn
|
||||
std::error::Error` will work as a source.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub struct MyError {
|
||||
msg: String,
|
||||
#[source] // optional if field name is `source`
|
||||
source: anyhow::Error,
|
||||
}
|
||||
```
|
||||
|
||||
- The Error trait's `provide()` method is implemented to provide whichever field
|
||||
has a type named `Backtrace`, if any, as a `std::backtrace::Backtrace`.
|
||||
|
||||
```rust
|
||||
use std::backtrace::Backtrace;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub struct MyError {
|
||||
msg: String,
|
||||
backtrace: Backtrace, // automatically detected
|
||||
}
|
||||
```
|
||||
|
||||
- If a field is both a source (named `source`, or has `#[source]` or `#[from]`
|
||||
attribute) *and* is marked `#[backtrace]`, then the Error trait's `provide()`
|
||||
method is forwarded to the source's `provide` so that both layers of the error
|
||||
share the same backtrace.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
Io {
|
||||
#[backtrace]
|
||||
source: io::Error,
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
- Errors may use `error(transparent)` to forward the source and Display methods
|
||||
straight through to an underlying error without adding an additional message.
|
||||
This would be appropriate for enums that need an "anything else" variant.
|
||||
|
||||
```rust
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
...
|
||||
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error), // source and Display delegate to anyhow::Error
|
||||
}
|
||||
```
|
||||
|
||||
Another use case is hiding implementation details of an error representation
|
||||
behind an opaque error type, so that the representation is able to evolve
|
||||
without breaking the crate's public API.
|
||||
|
||||
```rust
|
||||
// PublicError is public, but opaque and easy to keep compatible.
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct PublicError(#[from] ErrorRepr);
|
||||
|
||||
impl PublicError {
|
||||
// Accessors for anything we do want to expose publicly.
|
||||
}
|
||||
|
||||
// Private and free to change across minor version of the crate.
|
||||
#[derive(Error, Debug)]
|
||||
enum ErrorRepr {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
- See also the [`anyhow`] library for a convenient single error type to use in
|
||||
application code.
|
||||
|
||||
[`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
|
||||
<br>
|
||||
|
||||
## Comparison to anyhow
|
||||
|
||||
Use thiserror if you care about designing your own dedicated error type(s) so
|
||||
that the caller receives exactly the information that you choose in the event of
|
||||
failure. This most often applies to library-like code. Use [Anyhow] if you don't
|
||||
care what error type your functions return, you just want it to be easy. This is
|
||||
common in application-like code.
|
||||
|
||||
[Anyhow]: https://github.com/dtolnay/anyhow
|
||||
|
||||
<br>
|
||||
|
||||
#### License
|
||||
|
||||
<sup>
|
||||
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
|
||||
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
|
||||
</sup>
|
||||
|
||||
<br>
|
||||
|
||||
<sub>
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
|
||||
be dual licensed as above, without any additional terms or conditions.
|
||||
</sub>
|
119
vendor/thiserror/build.rs
vendored
Normal file
119
vendor/thiserror/build.rs
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::path::Path;
|
||||
use std::process::{self, Command, Stdio};
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build/probe.rs");
|
||||
|
||||
let error_generic_member_access;
|
||||
let consider_rustc_bootstrap;
|
||||
if compile_probe(false) {
|
||||
// This is a nightly or dev compiler, so it supports unstable features
|
||||
// regardless of RUSTC_BOOTSTRAP. No need to rerun build script if
|
||||
// RUSTC_BOOTSTRAP is changed.
|
||||
error_generic_member_access = true;
|
||||
consider_rustc_bootstrap = false;
|
||||
} else if let Some(rustc_bootstrap) = env::var_os("RUSTC_BOOTSTRAP") {
|
||||
if compile_probe(true) {
|
||||
// This is a stable or beta compiler for which the user has set
|
||||
// RUSTC_BOOTSTRAP to turn on unstable features. Rerun build script
|
||||
// if they change it.
|
||||
error_generic_member_access = true;
|
||||
consider_rustc_bootstrap = true;
|
||||
} else if rustc_bootstrap == "1" {
|
||||
// This compiler does not support the generic member access API in
|
||||
// the form that thiserror expects. No need to pay attention to
|
||||
// RUSTC_BOOTSTRAP.
|
||||
error_generic_member_access = false;
|
||||
consider_rustc_bootstrap = false;
|
||||
} else {
|
||||
// This is a stable or beta compiler for which RUSTC_BOOTSTRAP is
|
||||
// set to restrict the use of unstable features by this crate.
|
||||
error_generic_member_access = false;
|
||||
consider_rustc_bootstrap = true;
|
||||
}
|
||||
} else {
|
||||
// Without RUSTC_BOOTSTRAP, this compiler does not support the generic
|
||||
// member access API in the form that thiserror expects, but try again
|
||||
// if the user turns on unstable features.
|
||||
error_generic_member_access = false;
|
||||
consider_rustc_bootstrap = true;
|
||||
}
|
||||
|
||||
if error_generic_member_access {
|
||||
println!("cargo:rustc-cfg=error_generic_member_access");
|
||||
}
|
||||
|
||||
if consider_rustc_bootstrap {
|
||||
println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");
|
||||
}
|
||||
}
|
||||
|
||||
fn compile_probe(rustc_bootstrap: bool) -> bool {
|
||||
if env::var_os("RUSTC_STAGE").is_some() {
|
||||
// We are running inside rustc bootstrap. This is a highly non-standard
|
||||
// environment with issues such as:
|
||||
//
|
||||
// https://github.com/rust-lang/cargo/issues/11138
|
||||
// https://github.com/rust-lang/rust/issues/114839
|
||||
//
|
||||
// Let's just not use nightly features here.
|
||||
return false;
|
||||
}
|
||||
|
||||
let rustc = cargo_env_var("RUSTC");
|
||||
let out_dir = cargo_env_var("OUT_DIR");
|
||||
let probefile = Path::new("build").join("probe.rs");
|
||||
|
||||
// Make sure to pick up Cargo rustc configuration.
|
||||
let mut cmd = if let Some(wrapper) = env::var_os("RUSTC_WRAPPER") {
|
||||
let mut cmd = Command::new(wrapper);
|
||||
// The wrapper's first argument is supposed to be the path to rustc.
|
||||
cmd.arg(rustc);
|
||||
cmd
|
||||
} else {
|
||||
Command::new(rustc)
|
||||
};
|
||||
|
||||
if !rustc_bootstrap {
|
||||
cmd.env_remove("RUSTC_BOOTSTRAP");
|
||||
}
|
||||
|
||||
cmd.stderr(Stdio::null())
|
||||
.arg("--edition=2018")
|
||||
.arg("--crate-name=thiserror")
|
||||
.arg("--crate-type=lib")
|
||||
.arg("--emit=dep-info,metadata")
|
||||
.arg("--out-dir")
|
||||
.arg(out_dir)
|
||||
.arg(probefile);
|
||||
|
||||
if let Some(target) = env::var_os("TARGET") {
|
||||
cmd.arg("--target").arg(target);
|
||||
}
|
||||
|
||||
// If Cargo wants to set RUSTFLAGS, use that.
|
||||
if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
|
||||
if !rustflags.is_empty() {
|
||||
for arg in rustflags.split('\x1f') {
|
||||
cmd.arg(arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match cmd.status() {
|
||||
Ok(status) => status.success(),
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn cargo_env_var(key: &str) -> OsString {
|
||||
env::var_os(key).unwrap_or_else(|| {
|
||||
eprintln!(
|
||||
"Environment variable ${} is not set during execution of build script",
|
||||
key,
|
||||
);
|
||||
process::exit(1);
|
||||
})
|
||||
}
|
32
vendor/thiserror/build/probe.rs
vendored
Normal file
32
vendor/thiserror/build/probe.rs
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// This code exercises the surface area that we expect of the Error generic
|
||||
// member access API. If the current toolchain is able to compile it, then
|
||||
// thiserror is able to provide backtrace support.
|
||||
|
||||
#![feature(error_generic_member_access)]
|
||||
|
||||
use std::error::{Error, Request};
|
||||
use std::fmt::{self, Debug, Display};
|
||||
|
||||
struct MyError(Thing);
|
||||
struct Thing;
|
||||
|
||||
impl Debug for MyError {
|
||||
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for MyError {
|
||||
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for MyError {
|
||||
fn provide<'a>(&'a self, request: &mut Request<'a>) {
|
||||
request.provide_ref(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
// Include in sccache cache key.
|
||||
const _: Option<&str> = option_env!("RUSTC_BOOTSTRAP");
|
2
vendor/thiserror/rust-toolchain.toml
vendored
Normal file
2
vendor/thiserror/rust-toolchain.toml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
components = ["rust-src"]
|
50
vendor/thiserror/src/aserror.rs
vendored
Normal file
50
vendor/thiserror/src/aserror.rs
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
use std::error::Error;
|
||||
use std::panic::UnwindSafe;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait AsDynError<'a>: Sealed {
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a);
|
||||
}
|
||||
|
||||
impl<'a, T: Error + 'a> AsDynError<'a> for T {
|
||||
#[inline]
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDynError<'a> for dyn Error + 'a {
|
||||
#[inline]
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDynError<'a> for dyn Error + Send + 'a {
|
||||
#[inline]
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a {
|
||||
#[inline]
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
|
||||
#[inline]
|
||||
fn as_dyn_error(&self) -> &(dyn Error + 'a) {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait Sealed {}
|
||||
impl<'a, T: Error + 'a> Sealed for T {}
|
||||
impl<'a> Sealed for dyn Error + 'a {}
|
||||
impl<'a> Sealed for dyn Error + Send + 'a {}
|
||||
impl<'a> Sealed for dyn Error + Send + Sync + 'a {}
|
||||
impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {}
|
40
vendor/thiserror/src/display.rs
vendored
Normal file
40
vendor/thiserror/src/display.rs
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
use std::fmt::Display;
|
||||
use std::path::{self, Path, PathBuf};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait AsDisplay<'a> {
|
||||
// TODO: convert to generic associated type.
|
||||
// https://github.com/dtolnay/thiserror/pull/253
|
||||
type Target: Display;
|
||||
|
||||
fn as_display(&'a self) -> Self::Target;
|
||||
}
|
||||
|
||||
impl<'a, T> AsDisplay<'a> for &T
|
||||
where
|
||||
T: Display + 'a,
|
||||
{
|
||||
type Target = &'a T;
|
||||
|
||||
fn as_display(&'a self) -> Self::Target {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDisplay<'a> for Path {
|
||||
type Target = path::Display<'a>;
|
||||
|
||||
#[inline]
|
||||
fn as_display(&'a self) -> Self::Target {
|
||||
self.display()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsDisplay<'a> for PathBuf {
|
||||
type Target = path::Display<'a>;
|
||||
|
||||
#[inline]
|
||||
fn as_display(&'a self) -> Self::Target {
|
||||
self.display()
|
||||
}
|
||||
}
|
260
vendor/thiserror/src/lib.rs
vendored
Normal file
260
vendor/thiserror/src/lib.rs
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
//! [![github]](https://github.com/dtolnay/thiserror) [![crates-io]](https://crates.io/crates/thiserror) [![docs-rs]](https://docs.rs/thiserror)
|
||||
//!
|
||||
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
|
||||
//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
|
||||
//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
|
||||
//!
|
||||
//! <br>
|
||||
//!
|
||||
//! This library provides a convenient derive macro for the standard library's
|
||||
//! [`std::error::Error`] trait.
|
||||
//!
|
||||
//! [`std::error::Error`]: https://doc.rust-lang.org/std/error/trait.Error.html
|
||||
//!
|
||||
//! <br>
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use std::io;
|
||||
//! use thiserror::Error;
|
||||
//!
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum DataStoreError {
|
||||
//! #[error("data store disconnected")]
|
||||
//! Disconnect(#[from] io::Error),
|
||||
//! #[error("the data for key `{0}` is not available")]
|
||||
//! Redaction(String),
|
||||
//! #[error("invalid header (expected {expected:?}, found {found:?})")]
|
||||
//! InvalidHeader {
|
||||
//! expected: String,
|
||||
//! found: String,
|
||||
//! },
|
||||
//! #[error("unknown data store error")]
|
||||
//! Unknown,
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! <br>
|
||||
//!
|
||||
//! # Details
|
||||
//!
|
||||
//! - Thiserror deliberately does not appear in your public API. You get the
|
||||
//! same thing as if you had written an implementation of `std::error::Error`
|
||||
//! by hand, and switching from handwritten impls to thiserror or vice versa
|
||||
//! is not a breaking change.
|
||||
//!
|
||||
//! - Errors may be enums, structs with named fields, tuple structs, or unit
|
||||
//! structs.
|
||||
//!
|
||||
//! - A `Display` impl is generated for your error if you provide
|
||||
//! `#[error("...")]` messages on the struct or each variant of your enum, as
|
||||
//! shown above in the example.
|
||||
//!
|
||||
//! The messages support a shorthand for interpolating fields from the error.
|
||||
//!
|
||||
//! - `#[error("{var}")]` ⟶ `write!("{}", self.var)`
|
||||
//! - `#[error("{0}")]` ⟶ `write!("{}", self.0)`
|
||||
//! - `#[error("{var:?}")]` ⟶ `write!("{:?}", self.var)`
|
||||
//! - `#[error("{0:?}")]` ⟶ `write!("{:?}", self.0)`
|
||||
//!
|
||||
//! These shorthands can be used together with any additional format args,
|
||||
//! which may be arbitrary expressions. For example:
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use std::i32;
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum Error {
|
||||
//! #[error("invalid rdo_lookahead_frames {0} (expected < {})", i32::MAX)]
|
||||
//! InvalidLookahead(u32),
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! If one of the additional expression arguments needs to refer to a field of
|
||||
//! the struct or enum, then refer to named fields as `.var` and tuple fields
|
||||
//! as `.0`.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! # fn first_char(s: &String) -> char {
|
||||
//! # s.chars().next().unwrap()
|
||||
//! # }
|
||||
//! #
|
||||
//! # #[derive(Debug)]
|
||||
//! # struct Limits {
|
||||
//! # lo: usize,
|
||||
//! # hi: usize,
|
||||
//! # }
|
||||
//! #
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum Error {
|
||||
//! #[error("first letter must be lowercase but was {:?}", first_char(.0))]
|
||||
//! WrongCase(String),
|
||||
//! #[error("invalid index {idx}, expected at least {} and at most {}", .limits.lo, .limits.hi)]
|
||||
//! OutOfBounds { idx: usize, limits: Limits },
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! - A `From` impl is generated for each variant containing a `#[from]`
|
||||
//! attribute.
|
||||
//!
|
||||
//! Note that the variant must not contain any other fields beyond the source
|
||||
//! error and possibly a backtrace. A backtrace is captured from within the
|
||||
//! `From` impl if there is a field for it.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum MyError {
|
||||
//! Io {
|
||||
//! #[from]
|
||||
//! source: io::Error,
|
||||
//! backtrace: Backtrace,
|
||||
//! },
|
||||
//! }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - The Error trait's `source()` method is implemented to return whichever
|
||||
//! field has a `#[source]` attribute or is named `source`, if any. This is
|
||||
//! for identifying the underlying lower level error that caused your error.
|
||||
//!
|
||||
//! The `#[from]` attribute always implies that the same field is `#[source]`,
|
||||
//! so you don't ever need to specify both attributes.
|
||||
//!
|
||||
//! Any error type that implements `std::error::Error` or dereferences to `dyn
|
||||
//! std::error::Error` will work as a source.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # use std::fmt::{self, Display};
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub struct MyError {
|
||||
//! msg: String,
|
||||
//! #[source] // optional if field name is `source`
|
||||
//! source: anyhow::Error,
|
||||
//! }
|
||||
//! #
|
||||
//! # impl Display for MyError {
|
||||
//! # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
//! # unimplemented!()
|
||||
//! # }
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
//! - The Error trait's `provide()` method is implemented to provide whichever
|
||||
//! field has a type named `Backtrace`, if any, as a
|
||||
//! `std::backtrace::Backtrace`.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! use std::backtrace::Backtrace;
|
||||
//!
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub struct MyError {
|
||||
//! msg: String,
|
||||
//! backtrace: Backtrace, // automatically detected
|
||||
//! }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - If a field is both a source (named `source`, or has `#[source]` or
|
||||
//! `#[from]` attribute) *and* is marked `#[backtrace]`, then the Error
|
||||
//! trait's `provide()` method is forwarded to the source's `provide` so that
|
||||
//! both layers of the error share the same backtrace.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # const IGNORE: &str = stringify! {
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum MyError {
|
||||
//! Io {
|
||||
//! #[backtrace]
|
||||
//! source: io::Error,
|
||||
//! },
|
||||
//! }
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! - Errors may use `error(transparent)` to forward the source and Display
|
||||
//! methods straight through to an underlying error without adding an
|
||||
//! additional message. This would be appropriate for enums that need an
|
||||
//! "anything else" variant.
|
||||
//!
|
||||
//! ```
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! #[derive(Error, Debug)]
|
||||
//! pub enum MyError {
|
||||
//! # /*
|
||||
//! ...
|
||||
//! # */
|
||||
//!
|
||||
//! #[error(transparent)]
|
||||
//! Other(#[from] anyhow::Error), // source and Display delegate to anyhow::Error
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! Another use case is hiding implementation details of an error
|
||||
//! representation behind an opaque error type, so that the representation is
|
||||
//! able to evolve without breaking the crate's public API.
|
||||
//!
|
||||
//! ```
|
||||
//! # use thiserror::Error;
|
||||
//! #
|
||||
//! // PublicError is public, but opaque and easy to keep compatible.
|
||||
//! #[derive(Error, Debug)]
|
||||
//! #[error(transparent)]
|
||||
//! pub struct PublicError(#[from] ErrorRepr);
|
||||
//!
|
||||
//! impl PublicError {
|
||||
//! // Accessors for anything we do want to expose publicly.
|
||||
//! }
|
||||
//!
|
||||
//! // Private and free to change across minor version of the crate.
|
||||
//! #[derive(Error, Debug)]
|
||||
//! enum ErrorRepr {
|
||||
//! # /*
|
||||
//! ...
|
||||
//! # */
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! - See also the [`anyhow`] library for a convenient single error type to use
|
||||
//! in application code.
|
||||
//!
|
||||
//! [`anyhow`]: https://github.com/dtolnay/anyhow
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/thiserror/1.0.56")]
|
||||
#![allow(
|
||||
clippy::module_name_repetitions,
|
||||
clippy::needless_lifetimes,
|
||||
clippy::return_self_not_must_use,
|
||||
clippy::wildcard_imports
|
||||
)]
|
||||
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]
|
||||
|
||||
#[cfg(all(thiserror_nightly_testing, not(error_generic_member_access)))]
|
||||
compile_error!("Build script probe failed to compile.");
|
||||
|
||||
mod aserror;
|
||||
mod display;
|
||||
#[cfg(error_generic_member_access)]
|
||||
mod provide;
|
||||
|
||||
pub use thiserror_impl::*;
|
||||
|
||||
// Not public API.
|
||||
#[doc(hidden)]
|
||||
pub mod __private {
|
||||
#[doc(hidden)]
|
||||
pub use crate::aserror::AsDynError;
|
||||
#[doc(hidden)]
|
||||
pub use crate::display::AsDisplay;
|
||||
#[cfg(error_generic_member_access)]
|
||||
#[doc(hidden)]
|
||||
pub use crate::provide::ThiserrorProvide;
|
||||
}
|
20
vendor/thiserror/src/provide.rs
vendored
Normal file
20
vendor/thiserror/src/provide.rs
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
use std::error::{Error, Request};
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait ThiserrorProvide: Sealed {
|
||||
fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>);
|
||||
}
|
||||
|
||||
impl<T> ThiserrorProvide for T
|
||||
where
|
||||
T: Error + ?Sized,
|
||||
{
|
||||
#[inline]
|
||||
fn thiserror_provide<'a>(&'a self, request: &mut Request<'a>) {
|
||||
self.provide(request);
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub trait Sealed {}
|
||||
impl<T: Error + ?Sized> Sealed for T {}
|
7
vendor/thiserror/tests/compiletest.rs
vendored
Normal file
7
vendor/thiserror/tests/compiletest.rs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
#[rustversion::attr(not(nightly), ignore)]
|
||||
#[cfg_attr(miri, ignore)]
|
||||
#[test]
|
||||
fn ui() {
|
||||
let t = trybuild::TestCases::new();
|
||||
t.compile_fail("tests/ui/*.rs");
|
||||
}
|
274
vendor/thiserror/tests/test_backtrace.rs
vendored
Normal file
274
vendor/thiserror/tests/test_backtrace.rs
vendored
Normal file
@ -0,0 +1,274 @@
|
||||
#![cfg_attr(thiserror_nightly_testing, feature(error_generic_member_access))]
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct Inner;
|
||||
|
||||
#[cfg(thiserror_nightly_testing)]
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct InnerBacktrace {
|
||||
backtrace: std::backtrace::Backtrace,
|
||||
}
|
||||
|
||||
#[cfg(thiserror_nightly_testing)]
|
||||
pub mod structs {
|
||||
use super::{Inner, InnerBacktrace};
|
||||
use std::backtrace::Backtrace;
|
||||
use std::error::{self, Error};
|
||||
use std::sync::Arc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct PlainBacktrace {
|
||||
backtrace: Backtrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ExplicitBacktrace {
|
||||
#[backtrace]
|
||||
backtrace: Backtrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptBacktrace {
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ArcBacktrace {
|
||||
#[backtrace]
|
||||
backtrace: Arc<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct BacktraceFrom {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Backtrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct CombinedBacktraceFrom {
|
||||
#[from]
|
||||
#[backtrace]
|
||||
source: InnerBacktrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptBacktraceFrom {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ArcBacktraceFrom {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Arc<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct AnyhowBacktrace {
|
||||
#[backtrace]
|
||||
source: anyhow::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct BoxDynErrorBacktrace {
|
||||
#[backtrace]
|
||||
source: Box<dyn Error>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_backtrace() {
|
||||
let error = PlainBacktrace {
|
||||
backtrace: Backtrace::capture(),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ExplicitBacktrace {
|
||||
backtrace: Backtrace::capture(),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = OptBacktrace {
|
||||
backtrace: Some(Backtrace::capture()),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ArcBacktrace {
|
||||
backtrace: Arc::new(Backtrace::capture()),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = BacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = CombinedBacktraceFrom::from(InnerBacktrace {
|
||||
backtrace: Backtrace::capture(),
|
||||
});
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = OptBacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ArcBacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = AnyhowBacktrace {
|
||||
source: anyhow::Error::msg("..."),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = BoxDynErrorBacktrace {
|
||||
source: Box::new(PlainBacktrace {
|
||||
backtrace: Backtrace::capture(),
|
||||
}),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(thiserror_nightly_testing)]
|
||||
pub mod enums {
|
||||
use super::{Inner, InnerBacktrace};
|
||||
use std::backtrace::Backtrace;
|
||||
use std::error;
|
||||
use std::sync::Arc;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum PlainBacktrace {
|
||||
#[error("...")]
|
||||
Test { backtrace: Backtrace },
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ExplicitBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[backtrace]
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OptBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ArcBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[backtrace]
|
||||
backtrace: Arc<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum BacktraceFrom {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum CombinedBacktraceFrom {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[from]
|
||||
#[backtrace]
|
||||
source: InnerBacktrace,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OptBacktraceFrom {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ArcBacktraceFrom {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[from]
|
||||
source: Inner,
|
||||
#[backtrace]
|
||||
backtrace: Arc<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_backtrace() {
|
||||
let error = PlainBacktrace::Test {
|
||||
backtrace: Backtrace::capture(),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ExplicitBacktrace::Test {
|
||||
backtrace: Backtrace::capture(),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = OptBacktrace::Test {
|
||||
backtrace: Some(Backtrace::capture()),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ArcBacktrace::Test {
|
||||
backtrace: Arc::new(Backtrace::capture()),
|
||||
};
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = BacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = CombinedBacktraceFrom::from(InnerBacktrace {
|
||||
backtrace: Backtrace::capture(),
|
||||
});
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = OptBacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
|
||||
let error = ArcBacktraceFrom::from(Inner);
|
||||
assert!(error::request_ref::<Backtrace>(&error).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(not(thiserror_nightly_testing), ignore)]
|
||||
fn test_backtrace() {}
|
10
vendor/thiserror/tests/test_deprecated.rs
vendored
Normal file
10
vendor/thiserror/tests/test_deprecated.rs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#![deny(deprecated, clippy::all, clippy::pedantic)]
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[deprecated]
|
||||
#[error("...")]
|
||||
Deprecated,
|
||||
}
|
303
vendor/thiserror/tests/test_display.rs
vendored
Normal file
303
vendor/thiserror/tests/test_display.rs
vendored
Normal file
@ -0,0 +1,303 @@
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
|
||||
use std::fmt::{self, Display};
|
||||
use thiserror::Error;
|
||||
|
||||
fn assert<T: Display>(expected: &str, value: T) {
|
||||
assert_eq!(expected, value.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_braced() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("braced error: {msg}")]
|
||||
struct Error {
|
||||
msg: String,
|
||||
}
|
||||
|
||||
let msg = "T".to_owned();
|
||||
assert("braced error: T", Error { msg });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_braced_unused() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("braced error")]
|
||||
struct Error {
|
||||
extra: usize,
|
||||
}
|
||||
|
||||
assert("braced error", Error { extra: 0 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tuple() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("tuple error: {0}")]
|
||||
struct Error(usize);
|
||||
|
||||
assert("tuple error: 0", Error(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_unit() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("unit error")]
|
||||
struct Error;
|
||||
|
||||
assert("unit error", Error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_enum() {
|
||||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("braced error: {id}")]
|
||||
Braced { id: usize },
|
||||
#[error("tuple error: {0}")]
|
||||
Tuple(usize),
|
||||
#[error("unit error")]
|
||||
Unit,
|
||||
}
|
||||
|
||||
assert("braced error: 0", Error::Braced { id: 0 });
|
||||
assert("tuple error: 0", Error::Tuple(0));
|
||||
assert("unit error", Error::Unit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_constants() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{MSG}: {id:?} (code {CODE:?})")]
|
||||
struct Error {
|
||||
id: &'static str,
|
||||
}
|
||||
|
||||
const MSG: &str = "failed to do";
|
||||
const CODE: usize = 9;
|
||||
|
||||
assert("failed to do: \"\" (code 9)", Error { id: "" });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_inherit() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{0}")]
|
||||
enum Error {
|
||||
Some(&'static str),
|
||||
#[error("other error")]
|
||||
Other(&'static str),
|
||||
}
|
||||
|
||||
assert("some error", Error::Some("some error"));
|
||||
assert("other error", Error::Other("..."));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_brace_escape() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("fn main() {{}}")]
|
||||
struct Error;
|
||||
|
||||
assert("fn main() {}", Error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_expr() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("1 + 1 = {}", 1 + 1)]
|
||||
struct Error;
|
||||
assert("1 + 1 = 2", Error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("!bool = {}", not(.0))]
|
||||
struct Error(bool);
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn not(bool: &bool) -> bool {
|
||||
!*bool
|
||||
}
|
||||
|
||||
assert("!bool = false", Error(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_match() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{}: {0}", match .1 {
|
||||
Some(n) => format!("error occurred with {}", n),
|
||||
None => "there was an empty error".to_owned(),
|
||||
})]
|
||||
struct Error(String, Option<usize>);
|
||||
|
||||
assert(
|
||||
"error occurred with 1: ...",
|
||||
Error("...".to_owned(), Some(1)),
|
||||
);
|
||||
assert(
|
||||
"there was an empty error: ...",
|
||||
Error("...".to_owned(), None),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_nested_display() {
|
||||
// Same behavior as the one in `test_match`, but without String allocations.
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{}", {
|
||||
struct Msg<'a>(&'a String, &'a Option<usize>);
|
||||
impl<'a> Display for Msg<'a> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.1 {
|
||||
Some(n) => write!(formatter, "error occurred with {}", n),
|
||||
None => write!(formatter, "there was an empty error"),
|
||||
}?;
|
||||
write!(formatter, ": {}", self.0)
|
||||
}
|
||||
}
|
||||
Msg(.0, .1)
|
||||
})]
|
||||
struct Error(String, Option<usize>);
|
||||
|
||||
assert(
|
||||
"error occurred with 1: ...",
|
||||
Error("...".to_owned(), Some(1)),
|
||||
);
|
||||
assert(
|
||||
"there was an empty error: ...",
|
||||
Error("...".to_owned(), None),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_void() {
|
||||
#[allow(clippy::empty_enum)]
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum Error {}
|
||||
|
||||
let _: Error;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_mixed() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("a={a} :: b={} :: c={c} :: d={d}", 1, c = 2, d = 3)]
|
||||
struct Error {
|
||||
a: usize,
|
||||
d: usize,
|
||||
}
|
||||
|
||||
assert("a=0 :: b=1 :: c=2 :: d=3", Error { a: 0, d: 0 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ints() {
|
||||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("error {0}")]
|
||||
Tuple(usize, usize),
|
||||
#[error("error {0}", '?')]
|
||||
Struct { v: usize },
|
||||
}
|
||||
|
||||
assert("error 9", Error::Tuple(9, 0));
|
||||
assert("error ?", Error::Struct { v: 0 });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_trailing_comma() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error(
|
||||
"error {0}",
|
||||
)]
|
||||
#[rustfmt::skip]
|
||||
struct Error(char);
|
||||
|
||||
assert("error ?", Error('?'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_field() {
|
||||
#[derive(Debug)]
|
||||
struct Inner {
|
||||
data: usize,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{}", .0.data)]
|
||||
struct Error(Inner);
|
||||
|
||||
assert("0", Error(Inner { data: 0 }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_macro_rules() {
|
||||
// Regression test for https://github.com/dtolnay/thiserror/issues/86
|
||||
|
||||
macro_rules! decl_error {
|
||||
($variant:ident($value:ident)) => {
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error0 {
|
||||
#[error("{0:?}")]
|
||||
$variant($value),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error("{0:?}")]
|
||||
pub enum Error1 {
|
||||
$variant($value),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
decl_error!(Repro(u8));
|
||||
|
||||
assert("0", Error0::Repro(0));
|
||||
assert("0", Error1::Repro(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_raw() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("braced raw error: {r#fn}")]
|
||||
struct Error {
|
||||
r#fn: &'static str,
|
||||
}
|
||||
|
||||
assert("braced raw error: T", Error { r#fn: "T" });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_raw_enum() {
|
||||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("braced raw error: {r#fn}")]
|
||||
Braced { r#fn: &'static str },
|
||||
}
|
||||
|
||||
assert("braced raw error: T", Error::Braced { r#fn: "T" });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_raw_conflict() {
|
||||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("braced raw error: {r#func}, {func}", func = "U")]
|
||||
Braced { r#func: &'static str },
|
||||
}
|
||||
|
||||
assert("braced raw error: T, U", Error::Braced { r#func: "T" });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_keyword() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error("error: {type}", type = 1)]
|
||||
struct Error;
|
||||
|
||||
assert("error: 1", Error);
|
||||
}
|
56
vendor/thiserror/tests/test_error.rs
vendored
Normal file
56
vendor/thiserror/tests/test_error.rs
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::fmt::{self, Display};
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
|
||||
macro_rules! unimplemented_display {
|
||||
($ty:ty) => {
|
||||
impl Display for $ty {
|
||||
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
struct BracedError {
|
||||
msg: String,
|
||||
pos: usize,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
struct TupleError(String, usize);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
struct UnitError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
struct WithSource {
|
||||
#[source]
|
||||
cause: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
struct WithAnyhow {
|
||||
#[source]
|
||||
cause: anyhow::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum EnumError {
|
||||
Braced {
|
||||
#[source]
|
||||
cause: io::Error,
|
||||
},
|
||||
Tuple(#[source] io::Error),
|
||||
Unit,
|
||||
}
|
||||
|
||||
unimplemented_display!(BracedError);
|
||||
unimplemented_display!(TupleError);
|
||||
unimplemented_display!(UnitError);
|
||||
unimplemented_display!(WithSource);
|
||||
unimplemented_display!(WithAnyhow);
|
||||
unimplemented_display!(EnumError);
|
88
vendor/thiserror/tests/test_expr.rs
vendored
Normal file
88
vendor/thiserror/tests/test_expr.rs
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
#![allow(clippy::iter_cloned_collect, clippy::uninlined_format_args)]
|
||||
|
||||
use std::fmt::Display;
|
||||
use thiserror::Error;
|
||||
|
||||
// Some of the elaborate cases from the rcc codebase, which is a C compiler in
|
||||
// Rust. https://github.com/jyn514/rcc/blob/0.8.0/src/data/error.rs
|
||||
#[derive(Error, Debug)]
|
||||
pub enum CompilerError {
|
||||
#[error("cannot shift {} by {maximum} or more bits (got {current})", if *.is_left { "left" } else { "right" })]
|
||||
TooManyShiftBits {
|
||||
is_left: bool,
|
||||
maximum: u64,
|
||||
current: u64,
|
||||
},
|
||||
|
||||
#[error("#error {}", (.0).iter().copied().collect::<Vec<_>>().join(" "))]
|
||||
User(Vec<&'static str>),
|
||||
|
||||
#[error("overflow while parsing {}integer literal",
|
||||
if let Some(signed) = .is_signed {
|
||||
if *signed { "signed "} else { "unsigned "}
|
||||
} else {
|
||||
""
|
||||
}
|
||||
)]
|
||||
IntegerOverflow { is_signed: Option<bool> },
|
||||
|
||||
#[error("overflow while parsing {}integer literal", match .is_signed {
|
||||
Some(true) => "signed ",
|
||||
Some(false) => "unsigned ",
|
||||
None => "",
|
||||
})]
|
||||
IntegerOverflow2 { is_signed: Option<bool> },
|
||||
}
|
||||
|
||||
// Examples drawn from Rustup.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum RustupError {
|
||||
#[error(
|
||||
"toolchain '{name}' does not contain component {component}{}",
|
||||
.suggestion
|
||||
.as_ref()
|
||||
.map_or_else(String::new, |s| format!("; did you mean '{}'?", s)),
|
||||
)]
|
||||
UnknownComponent {
|
||||
name: String,
|
||||
component: String,
|
||||
suggestion: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
fn assert<T: Display>(expected: &str, value: T) {
|
||||
assert_eq!(expected, value.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rcc() {
|
||||
assert(
|
||||
"cannot shift left by 32 or more bits (got 50)",
|
||||
CompilerError::TooManyShiftBits {
|
||||
is_left: true,
|
||||
maximum: 32,
|
||||
current: 50,
|
||||
},
|
||||
);
|
||||
|
||||
assert("#error A B C", CompilerError::User(vec!["A", "B", "C"]));
|
||||
|
||||
assert(
|
||||
"overflow while parsing signed integer literal",
|
||||
CompilerError::IntegerOverflow {
|
||||
is_signed: Some(true),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rustup() {
|
||||
assert(
|
||||
"toolchain 'nightly' does not contain component clipy; did you mean 'clippy'?",
|
||||
RustupError::UnknownComponent {
|
||||
name: "nightly".to_owned(),
|
||||
component: "clipy".to_owned(),
|
||||
suggestion: Some("clippy".to_owned()),
|
||||
},
|
||||
);
|
||||
}
|
64
vendor/thiserror/tests/test_from.rs
vendored
Normal file
64
vendor/thiserror/tests/test_from.rs
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
#![allow(clippy::extra_unused_type_parameters)]
|
||||
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorStruct {
|
||||
#[from]
|
||||
source: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorStructOptional {
|
||||
#[from]
|
||||
source: Option<io::Error>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorTuple(#[from] io::Error);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorTupleOptional(#[from] Option<io::Error>);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum ErrorEnum {
|
||||
Test {
|
||||
#[from]
|
||||
source: io::Error,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum ErrorEnumOptional {
|
||||
Test {
|
||||
#[from]
|
||||
source: Option<io::Error>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum Many {
|
||||
Any(#[from] anyhow::Error),
|
||||
Io(#[from] io::Error),
|
||||
}
|
||||
|
||||
fn assert_impl<T: From<io::Error>>() {}
|
||||
|
||||
#[test]
|
||||
fn test_from() {
|
||||
assert_impl::<ErrorStruct>();
|
||||
assert_impl::<ErrorStructOptional>();
|
||||
assert_impl::<ErrorTuple>();
|
||||
assert_impl::<ErrorTupleOptional>();
|
||||
assert_impl::<ErrorEnum>();
|
||||
assert_impl::<ErrorEnumOptional>();
|
||||
assert_impl::<Many>();
|
||||
}
|
161
vendor/thiserror/tests/test_generics.rs
vendored
Normal file
161
vendor/thiserror/tests/test_generics.rs
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
#![allow(clippy::needless_late_init, clippy::uninlined_format_args)]
|
||||
|
||||
use std::fmt::{self, Debug, Display};
|
||||
use thiserror::Error;
|
||||
|
||||
pub struct NoFormat;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DebugOnly;
|
||||
|
||||
pub struct DisplayOnly;
|
||||
|
||||
impl Display for DisplayOnly {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str("display only")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DebugAndDisplay;
|
||||
|
||||
impl Display for DebugAndDisplay {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str("debug and display")
|
||||
}
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Display for EnumDebugField<E>
|
||||
// where
|
||||
// E: Debug;
|
||||
//
|
||||
// impl<E> Error for EnumDebugField<E>
|
||||
// where
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
pub enum EnumDebugGeneric<E> {
|
||||
#[error("{0:?}")]
|
||||
FatalError(E),
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Display for EnumFromGeneric<E>;
|
||||
//
|
||||
// impl<E> Error for EnumFromGeneric<E>
|
||||
// where
|
||||
// EnumDebugGeneric<E>: Error + 'static,
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
pub enum EnumFromGeneric<E> {
|
||||
#[error("enum from generic")]
|
||||
Source(#[from] EnumDebugGeneric<E>),
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<HasDisplay, HasDebug, HasNeither> Display
|
||||
// for EnumCompound<HasDisplay, HasDebug, HasNeither>
|
||||
// where
|
||||
// HasDisplay: Display,
|
||||
// HasDebug: Debug;
|
||||
//
|
||||
// impl<HasDisplay, HasDebug, HasNeither> Error
|
||||
// for EnumCompound<HasDisplay, HasDebug, HasNeither>
|
||||
// where
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error)]
|
||||
pub enum EnumCompound<HasDisplay, HasDebug, HasNeither> {
|
||||
#[error("{0} {1:?}")]
|
||||
DisplayDebug(HasDisplay, HasDebug),
|
||||
#[error("{0}")]
|
||||
Display(HasDisplay, HasNeither),
|
||||
#[error("{1:?}")]
|
||||
Debug(HasNeither, HasDebug),
|
||||
}
|
||||
|
||||
impl<HasDisplay, HasDebug, HasNeither> Debug for EnumCompound<HasDisplay, HasDebug, HasNeither> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.write_str("EnumCompound")
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_display_enum_compound() {
|
||||
let mut instance: EnumCompound<DisplayOnly, DebugOnly, NoFormat>;
|
||||
|
||||
instance = EnumCompound::DisplayDebug(DisplayOnly, DebugOnly);
|
||||
assert_eq!(format!("{}", instance), "display only DebugOnly");
|
||||
|
||||
instance = EnumCompound::Display(DisplayOnly, NoFormat);
|
||||
assert_eq!(format!("{}", instance), "display only");
|
||||
|
||||
instance = EnumCompound::Debug(NoFormat, DebugOnly);
|
||||
assert_eq!(format!("{}", instance), "DebugOnly");
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Display for EnumTransparentGeneric<E>
|
||||
// where
|
||||
// E: Display;
|
||||
//
|
||||
// impl<E> Error for EnumTransparentGeneric<E>
|
||||
// where
|
||||
// E: Error,
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
pub enum EnumTransparentGeneric<E> {
|
||||
#[error(transparent)]
|
||||
Other(E),
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Display for StructDebugGeneric<E>
|
||||
// where
|
||||
// E: Debug;
|
||||
//
|
||||
// impl<E> Error for StructDebugGeneric<E>
|
||||
// where
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{underlying:?}")]
|
||||
pub struct StructDebugGeneric<E> {
|
||||
pub underlying: E,
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Error for StructFromGeneric<E>
|
||||
// where
|
||||
// StructDebugGeneric<E>: Error + 'static,
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
pub struct StructFromGeneric<E> {
|
||||
#[from]
|
||||
pub source: StructDebugGeneric<E>,
|
||||
}
|
||||
|
||||
// Should expand to:
|
||||
//
|
||||
// impl<E> Display for StructTransparentGeneric<E>
|
||||
// where
|
||||
// E: Display;
|
||||
//
|
||||
// impl<E> Error for StructTransparentGeneric<E>
|
||||
// where
|
||||
// E: Error,
|
||||
// Self: Debug + Display;
|
||||
//
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct StructTransparentGeneric<E>(E);
|
18
vendor/thiserror/tests/test_lints.rs
vendored
Normal file
18
vendor/thiserror/tests/test_lints.rs
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
use thiserror::Error;
|
||||
|
||||
pub use std::error::Error;
|
||||
|
||||
#[test]
|
||||
fn test_unused_qualifications() {
|
||||
#![deny(unused_qualifications)]
|
||||
|
||||
// Expansion of derive(Error) macro can't know whether something like
|
||||
// std::error::Error is already imported in the caller's scope so it must
|
||||
// suppress unused_qualifications.
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error("...")]
|
||||
pub struct MyError;
|
||||
|
||||
let _: MyError;
|
||||
}
|
105
vendor/thiserror/tests/test_option.rs
vendored
Normal file
105
vendor/thiserror/tests/test_option.rs
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
#![cfg_attr(thiserror_nightly_testing, feature(error_generic_member_access))]
|
||||
|
||||
#[cfg(thiserror_nightly_testing)]
|
||||
pub mod structs {
|
||||
use std::backtrace::Backtrace;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptSourceNoBacktrace {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptSourceAlwaysBacktrace {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
backtrace: Backtrace,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct NoSourceOptBacktrace {
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct AlwaysSourceOptBacktrace {
|
||||
source: anyhow::Error,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct OptSourceOptBacktrace {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(thiserror_nightly_testing)]
|
||||
pub mod enums {
|
||||
use std::backtrace::Backtrace;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OptSourceNoBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OptSourceAlwaysBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
backtrace: Backtrace,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum NoSourceOptBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum AlwaysSourceOptBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
source: anyhow::Error,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum OptSourceOptBacktrace {
|
||||
#[error("...")]
|
||||
Test {
|
||||
#[source]
|
||||
source: Option<anyhow::Error>,
|
||||
#[backtrace]
|
||||
backtrace: Option<Backtrace>,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(not(thiserror_nightly_testing), ignore)]
|
||||
fn test_option() {}
|
37
vendor/thiserror/tests/test_path.rs
vendored
Normal file
37
vendor/thiserror/tests/test_path.rs
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
use ref_cast::RefCast;
|
||||
use std::fmt::Display;
|
||||
use std::path::{Path, PathBuf};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("failed to read '{file}'")]
|
||||
struct StructPathBuf {
|
||||
file: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, RefCast)]
|
||||
#[repr(C)]
|
||||
#[error("failed to read '{file}'")]
|
||||
struct StructPath {
|
||||
file: Path,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum EnumPathBuf {
|
||||
#[error("failed to read '{0}'")]
|
||||
Read(PathBuf),
|
||||
}
|
||||
|
||||
fn assert<T: Display>(expected: &str, value: T) {
|
||||
assert_eq!(expected, value.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_display() {
|
||||
let path = Path::new("/thiserror");
|
||||
let file = path.to_owned();
|
||||
assert("failed to read '/thiserror'", StructPathBuf { file });
|
||||
let file = path.to_owned();
|
||||
assert("failed to read '/thiserror'", EnumPathBuf::Read(file));
|
||||
assert("failed to read '/thiserror'", StructPath::ref_cast(path));
|
||||
}
|
65
vendor/thiserror/tests/test_source.rs
vendored
Normal file
65
vendor/thiserror/tests/test_source.rs
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
use std::error::Error as StdError;
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("implicit source")]
|
||||
pub struct ImplicitSource {
|
||||
source: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("explicit source")]
|
||||
pub struct ExplicitSource {
|
||||
source: String,
|
||||
#[source]
|
||||
io: io::Error,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("boxed source")]
|
||||
pub struct BoxedSource {
|
||||
#[source]
|
||||
source: Box<dyn StdError + Send + 'static>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_implicit_source() {
|
||||
let io = io::Error::new(io::ErrorKind::Other, "oh no!");
|
||||
let error = ImplicitSource { source: io };
|
||||
error.source().unwrap().downcast_ref::<io::Error>().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_explicit_source() {
|
||||
let io = io::Error::new(io::ErrorKind::Other, "oh no!");
|
||||
let error = ExplicitSource {
|
||||
source: String::new(),
|
||||
io,
|
||||
};
|
||||
error.source().unwrap().downcast_ref::<io::Error>().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_boxed_source() {
|
||||
let source = Box::new(io::Error::new(io::ErrorKind::Other, "oh no!"));
|
||||
let error = BoxedSource { source };
|
||||
error.source().unwrap().downcast_ref::<io::Error>().unwrap();
|
||||
}
|
||||
|
||||
macro_rules! error_from_macro {
|
||||
($($variants:tt)*) => {
|
||||
#[derive(Error)]
|
||||
#[derive(Debug)]
|
||||
pub enum MacroSource {
|
||||
$($variants)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that we generate impls with the proper hygiene
|
||||
#[rustfmt::skip]
|
||||
error_from_macro! {
|
||||
#[error("Something")]
|
||||
Variant(#[from] io::Error)
|
||||
}
|
78
vendor/thiserror/tests/test_transparent.rs
vendored
Normal file
78
vendor/thiserror/tests/test_transparent.rs
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
use anyhow::anyhow;
|
||||
use std::error::Error as _;
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
|
||||
#[test]
|
||||
fn test_transparent_struct() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
struct Error(ErrorKind);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum ErrorKind {
|
||||
#[error("E0")]
|
||||
E0,
|
||||
#[error("E1")]
|
||||
E1(#[from] io::Error),
|
||||
}
|
||||
|
||||
let error = Error(ErrorKind::E0);
|
||||
assert_eq!("E0", error.to_string());
|
||||
assert!(error.source().is_none());
|
||||
|
||||
let io = io::Error::new(io::ErrorKind::Other, "oh no!");
|
||||
let error = Error(ErrorKind::from(io));
|
||||
assert_eq!("E1", error.to_string());
|
||||
error.source().unwrap().downcast_ref::<io::Error>().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transparent_enum() {
|
||||
#[derive(Error, Debug)]
|
||||
enum Error {
|
||||
#[error("this failed")]
|
||||
This,
|
||||
#[error(transparent)]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
let error = Error::This;
|
||||
assert_eq!("this failed", error.to_string());
|
||||
|
||||
let error = Error::Other(anyhow!("inner").context("outer"));
|
||||
assert_eq!("outer", error.to_string());
|
||||
assert_eq!("inner", error.source().unwrap().to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_anyhow() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
struct Any(#[from] anyhow::Error);
|
||||
|
||||
let error = Any::from(anyhow!("inner").context("outer"));
|
||||
assert_eq!("outer", error.to_string());
|
||||
assert_eq!("inner", error.source().unwrap().to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_static() {
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
struct Error<'a> {
|
||||
inner: ErrorKind<'a>,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum ErrorKind<'a> {
|
||||
#[error("unexpected token: {:?}", token)]
|
||||
Unexpected { token: &'a str },
|
||||
}
|
||||
|
||||
let error = Error {
|
||||
inner: ErrorKind::Unexpected { token: "error" },
|
||||
};
|
||||
assert_eq!("unexpected token: \"error\"", error.to_string());
|
||||
assert!(error.source().is_none());
|
||||
}
|
7
vendor/thiserror/tests/ui/bad-field-attr.rs
vendored
Normal file
7
vendor/thiserror/tests/ui/bad-field-attr.rs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct Error(#[error(transparent)] std::io::Error);
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/bad-field-attr.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/bad-field-attr.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: #[error(transparent)] needs to go outside the enum or struct, not on an individual field
|
||||
--> tests/ui/bad-field-attr.rs:5:18
|
||||
|
|
||||
5 | pub struct Error(#[error(transparent)] std::io::Error);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
15
vendor/thiserror/tests/ui/concat-display.rs
vendored
Normal file
15
vendor/thiserror/tests/ui/concat-display.rs
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
use thiserror::Error;
|
||||
|
||||
macro_rules! error_type {
|
||||
($name:ident, $what:expr) => {
|
||||
// Use #[error("invalid {}", $what)] instead.
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(concat!("invalid ", $what))]
|
||||
pub struct $name;
|
||||
};
|
||||
}
|
||||
|
||||
error_type!(Error, "foo");
|
||||
|
||||
fn main() {}
|
10
vendor/thiserror/tests/ui/concat-display.stderr
vendored
Normal file
10
vendor/thiserror/tests/ui/concat-display.stderr
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
error: expected string literal
|
||||
--> tests/ui/concat-display.rs:8:17
|
||||
|
|
||||
8 | #[error(concat!("invalid ", $what))]
|
||||
| ^^^^^^
|
||||
...
|
||||
13 | error_type!(Error, "foo");
|
||||
| ------------------------- in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
|
13
vendor/thiserror/tests/ui/duplicate-enum-source.rs
vendored
Normal file
13
vendor/thiserror/tests/ui/duplicate-enum-source.rs
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ErrorEnum {
|
||||
Confusing {
|
||||
#[source]
|
||||
a: std::io::Error,
|
||||
#[source]
|
||||
b: anyhow::Error,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/duplicate-enum-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/duplicate-enum-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: duplicate #[source] attribute
|
||||
--> tests/ui/duplicate-enum-source.rs:8:9
|
||||
|
|
||||
8 | #[source]
|
||||
| ^^^^^^^^^
|
8
vendor/thiserror/tests/ui/duplicate-fmt.rs
vendored
Normal file
8
vendor/thiserror/tests/ui/duplicate-fmt.rs
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
#[error("...")]
|
||||
pub struct Error;
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/duplicate-fmt.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/duplicate-fmt.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: only one #[error(...)] attribute is allowed
|
||||
--> tests/ui/duplicate-fmt.rs:5:1
|
||||
|
|
||||
5 | #[error("...")]
|
||||
| ^^^^^^^^^^^^^^^
|
11
vendor/thiserror/tests/ui/duplicate-struct-source.rs
vendored
Normal file
11
vendor/thiserror/tests/ui/duplicate-struct-source.rs
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub struct ErrorStruct {
|
||||
#[source]
|
||||
a: std::io::Error,
|
||||
#[source]
|
||||
b: anyhow::Error,
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/duplicate-struct-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/duplicate-struct-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: duplicate #[source] attribute
|
||||
--> tests/ui/duplicate-struct-source.rs:7:5
|
||||
|
|
||||
7 | #[source]
|
||||
| ^^^^^^^^^
|
8
vendor/thiserror/tests/ui/duplicate-transparent.rs
vendored
Normal file
8
vendor/thiserror/tests/ui/duplicate-transparent.rs
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
#[error(transparent)]
|
||||
pub struct Error(anyhow::Error);
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/duplicate-transparent.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/duplicate-transparent.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: duplicate #[error(transparent)] attribute
|
||||
--> tests/ui/duplicate-transparent.rs:5:1
|
||||
|
|
||||
5 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
14
vendor/thiserror/tests/ui/fallback-impl-with-display.rs
vendored
Normal file
14
vendor/thiserror/tests/ui/fallback-impl-with-display.rs
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
use std::fmt::{self, Display};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error]
|
||||
pub struct MyError;
|
||||
|
||||
impl Display for MyError {
|
||||
fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
16
vendor/thiserror/tests/ui/fallback-impl-with-display.stderr
vendored
Normal file
16
vendor/thiserror/tests/ui/fallback-impl-with-display.stderr
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
error: expected attribute arguments in parentheses: #[error(...)]
|
||||
--> tests/ui/fallback-impl-with-display.rs:5:3
|
||||
|
|
||||
5 | #[error]
|
||||
| ^^^^^
|
||||
|
||||
error[E0119]: conflicting implementations of trait `std::fmt::Display` for type `MyError`
|
||||
--> tests/ui/fallback-impl-with-display.rs:4:10
|
||||
|
|
||||
4 | #[derive(Error, Debug)]
|
||||
| ^^^^^ conflicting implementation for `MyError`
|
||||
...
|
||||
8 | impl Display for MyError {
|
||||
| ------------------------ first implementation here
|
||||
|
|
||||
= note: this error originates in the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
|
15
vendor/thiserror/tests/ui/from-backtrace-backtrace.rs
vendored
Normal file
15
vendor/thiserror/tests/ui/from-backtrace-backtrace.rs
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// https://github.com/dtolnay/thiserror/issues/163
|
||||
|
||||
use std::backtrace::Backtrace;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct Error(
|
||||
#[from]
|
||||
#[backtrace]
|
||||
std::io::Error,
|
||||
Backtrace,
|
||||
);
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: deriving From requires no fields other than source and backtrace
|
||||
--> tests/ui/from-backtrace-backtrace.rs:9:5
|
||||
|
|
||||
9 | #[from]
|
||||
| ^^^^^^^
|
11
vendor/thiserror/tests/ui/from-not-source.rs
vendored
Normal file
11
vendor/thiserror/tests/ui/from-not-source.rs
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub struct Error {
|
||||
#[source]
|
||||
source: std::io::Error,
|
||||
#[from]
|
||||
other: anyhow::Error,
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/from-not-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/from-not-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: #[from] is only supported on the source field, not any other field
|
||||
--> tests/ui/from-not-source.rs:7:5
|
||||
|
|
||||
7 | #[from]
|
||||
| ^^^^^^^
|
11
vendor/thiserror/tests/ui/invalid-input-impl-anyway.rs
vendored
Normal file
11
vendor/thiserror/tests/ui/invalid-input-impl-anyway.rs
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error]
|
||||
pub struct MyError;
|
||||
|
||||
fn main() {
|
||||
// No error on the following line. Thiserror emits an Error impl despite the
|
||||
// bad attribute.
|
||||
_ = &MyError as &dyn std::error::Error;
|
||||
}
|
5
vendor/thiserror/tests/ui/invalid-input-impl-anyway.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/invalid-input-impl-anyway.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: expected attribute arguments in parentheses: #[error(...)]
|
||||
--> tests/ui/invalid-input-impl-anyway.rs:4:3
|
||||
|
|
||||
4 | #[error]
|
||||
| ^^^^^
|
24
vendor/thiserror/tests/ui/lifetime.rs
vendored
Normal file
24
vendor/thiserror/tests/ui/lifetime.rs
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
use std::fmt::Debug;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("error")]
|
||||
struct Error<'a>(#[from] Inner<'a>);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{0}")]
|
||||
struct Inner<'a>(&'a str);
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
enum Enum<'a> {
|
||||
#[error("error")]
|
||||
Foo(#[from] Generic<&'a str>),
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("{0:?}")]
|
||||
struct Generic<T: Debug>(T);
|
||||
|
||||
fn main() -> Result<(), Error<'static>> {
|
||||
Err(Error(Inner("some text")))
|
||||
}
|
11
vendor/thiserror/tests/ui/lifetime.stderr
vendored
Normal file
11
vendor/thiserror/tests/ui/lifetime.stderr
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
|
||||
--> tests/ui/lifetime.rs:6:26
|
||||
|
|
||||
6 | struct Error<'a>(#[from] Inner<'a>);
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: non-static lifetimes are not allowed in the source of an error, because std::error::Error requires the source is dyn Error + 'static
|
||||
--> tests/ui/lifetime.rs:15:17
|
||||
|
|
||||
15 | Foo(#[from] Generic<&'a str>),
|
||||
| ^^^^^^^^^^^^^^^^
|
9
vendor/thiserror/tests/ui/missing-display.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/missing-display.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum MyError {
|
||||
First,
|
||||
Second,
|
||||
}
|
||||
|
||||
fn main() {}
|
13
vendor/thiserror/tests/ui/missing-display.stderr
vendored
Normal file
13
vendor/thiserror/tests/ui/missing-display.stderr
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
error[E0277]: `MyError` doesn't implement `std::fmt::Display`
|
||||
--> tests/ui/missing-display.rs:4:10
|
||||
|
|
||||
4 | pub enum MyError {
|
||||
| ^^^^^^^ `MyError` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `MyError`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `std::error::Error`
|
||||
--> $RUST/core/src/error.rs
|
||||
|
|
||||
| pub trait Error: Debug + Display {
|
||||
| ^^^^^^^ required by this bound in `Error`
|
10
vendor/thiserror/tests/ui/missing-fmt.rs
vendored
Normal file
10
vendor/thiserror/tests/ui/missing-fmt.rs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("...")]
|
||||
A(usize),
|
||||
B(usize),
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/missing-fmt.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/missing-fmt.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: missing #[error("...")] display attribute
|
||||
--> tests/ui/missing-fmt.rs:7:5
|
||||
|
|
||||
7 | B(usize),
|
||||
| ^^^^^^^^
|
12
vendor/thiserror/tests/ui/no-display.rs
vendored
Normal file
12
vendor/thiserror/tests/ui/no-display.rs
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct NoDisplay;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("thread: {thread}")]
|
||||
pub struct Error {
|
||||
thread: NoDisplay,
|
||||
}
|
||||
|
||||
fn main() {}
|
17
vendor/thiserror/tests/ui/no-display.stderr
vendored
Normal file
17
vendor/thiserror/tests/ui/no-display.stderr
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its trait bounds were not satisfied
|
||||
--> tests/ui/no-display.rs:7:9
|
||||
|
|
||||
4 | struct NoDisplay;
|
||||
| ---------------- doesn't satisfy `NoDisplay: std::fmt::Display`
|
||||
...
|
||||
7 | #[error("thread: {thread}")]
|
||||
| ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NoDisplay: std::fmt::Display`
|
||||
which is required by `&NoDisplay: AsDisplay<'_>`
|
||||
note: the trait `std::fmt::Display` must be implemented
|
||||
--> $RUST/core/src/fmt/mod.rs
|
||||
|
|
||||
| pub trait Display {
|
||||
| ^^^^^^^^^^^^^^^^^
|
12
vendor/thiserror/tests/ui/source-enum-not-error.rs
vendored
Normal file
12
vendor/thiserror/tests/ui/source-enum-not-error.rs
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NotError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum ErrorEnum {
|
||||
Broken { source: NotError },
|
||||
}
|
||||
|
||||
fn main() {}
|
22
vendor/thiserror/tests/ui/source-enum-not-error.stderr
vendored
Normal file
22
vendor/thiserror/tests/ui/source-enum-not-error.stderr
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied
|
||||
--> tests/ui/source-enum-not-error.rs:9:14
|
||||
|
|
||||
4 | pub struct NotError;
|
||||
| -------------------
|
||||
| |
|
||||
| doesn't satisfy `NotError: AsDynError<'_>`
|
||||
| doesn't satisfy `NotError: std::error::Error`
|
||||
...
|
||||
9 | Broken { source: NotError },
|
||||
| ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NotError: std::error::Error`
|
||||
which is required by `NotError: AsDynError<'_>`
|
||||
`&NotError: std::error::Error`
|
||||
which is required by `&NotError: AsDynError<'_>`
|
||||
note: the trait `std::error::Error` must be implemented
|
||||
--> $RUST/core/src/error.rs
|
||||
|
|
||||
| pub trait Error: Debug + Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
12
vendor/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs
vendored
Normal file
12
vendor/thiserror/tests/ui/source-enum-unnamed-field-not-error.rs
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NotError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub enum ErrorEnum {
|
||||
Broken(#[source] NotError),
|
||||
}
|
||||
|
||||
fn main() {}
|
22
vendor/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr
vendored
Normal file
22
vendor/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but its trait bounds were not satisfied
|
||||
--> tests/ui/source-enum-unnamed-field-not-error.rs:9:14
|
||||
|
|
||||
4 | pub struct NotError;
|
||||
| -------------------
|
||||
| |
|
||||
| doesn't satisfy `NotError: AsDynError<'_>`
|
||||
| doesn't satisfy `NotError: std::error::Error`
|
||||
...
|
||||
9 | Broken(#[source] NotError),
|
||||
| ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NotError: std::error::Error`
|
||||
which is required by `NotError: AsDynError<'_>`
|
||||
`&NotError: std::error::Error`
|
||||
which is required by `&NotError: AsDynError<'_>`
|
||||
note: the trait `std::error::Error` must be implemented
|
||||
--> $RUST/core/src/error.rs
|
||||
|
|
||||
| pub trait Error: Debug + Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
12
vendor/thiserror/tests/ui/source-struct-not-error.rs
vendored
Normal file
12
vendor/thiserror/tests/ui/source-struct-not-error.rs
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct NotError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorStruct {
|
||||
source: NotError,
|
||||
}
|
||||
|
||||
fn main() {}
|
21
vendor/thiserror/tests/ui/source-struct-not-error.stderr
vendored
Normal file
21
vendor/thiserror/tests/ui/source-struct-not-error.stderr
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied
|
||||
--> tests/ui/source-struct-not-error.rs:9:5
|
||||
|
|
||||
4 | struct NotError;
|
||||
| ---------------
|
||||
| |
|
||||
| method `as_dyn_error` not found for this struct
|
||||
| doesn't satisfy `NotError: AsDynError<'_>`
|
||||
| doesn't satisfy `NotError: std::error::Error`
|
||||
...
|
||||
9 | source: NotError,
|
||||
| ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NotError: std::error::Error`
|
||||
which is required by `NotError: AsDynError<'_>`
|
||||
note: the trait `std::error::Error` must be implemented
|
||||
--> $RUST/core/src/error.rs
|
||||
|
|
||||
| pub trait Error: Debug + Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
10
vendor/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs
vendored
Normal file
10
vendor/thiserror/tests/ui/source-struct-unnamed-field-not-error.rs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct NotError;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("...")]
|
||||
pub struct ErrorStruct(#[source] NotError);
|
||||
|
||||
fn main() {}
|
21
vendor/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr
vendored
Normal file
21
vendor/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its trait bounds were not satisfied
|
||||
--> tests/ui/source-struct-unnamed-field-not-error.rs:8:26
|
||||
|
|
||||
4 | struct NotError;
|
||||
| ---------------
|
||||
| |
|
||||
| method `as_dyn_error` not found for this struct
|
||||
| doesn't satisfy `NotError: AsDynError<'_>`
|
||||
| doesn't satisfy `NotError: std::error::Error`
|
||||
...
|
||||
8 | pub struct ErrorStruct(#[source] NotError);
|
||||
| ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`NotError: std::error::Error`
|
||||
which is required by `NotError: AsDynError<'_>`
|
||||
note: the trait `std::error::Error` must be implemented
|
||||
--> $RUST/core/src/error.rs
|
||||
|
|
||||
| pub trait Error: Debug + Display {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
8
vendor/thiserror/tests/ui/transparent-display.rs
vendored
Normal file
8
vendor/thiserror/tests/ui/transparent-display.rs
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
#[error("...")]
|
||||
pub struct Error(anyhow::Error);
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/transparent-display.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/transparent-display.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: cannot have both #[error(transparent)] and a display attribute
|
||||
--> tests/ui/transparent-display.rs:5:1
|
||||
|
|
||||
5 | #[error("...")]
|
||||
| ^^^^^^^^^^^^^^^
|
9
vendor/thiserror/tests/ui/transparent-enum-many.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/transparent-enum-many.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Other(anyhow::Error, String),
|
||||
}
|
||||
|
||||
fn main() {}
|
6
vendor/thiserror/tests/ui/transparent-enum-many.stderr
vendored
Normal file
6
vendor/thiserror/tests/ui/transparent-enum-many.stderr
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
error: #[error(transparent)] requires exactly one field
|
||||
--> tests/ui/transparent-enum-many.rs:5:5
|
||||
|
|
||||
5 | / #[error(transparent)]
|
||||
6 | | Other(anyhow::Error, String),
|
||||
| |________________________________^
|
9
vendor/thiserror/tests/ui/transparent-enum-not-error.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/transparent-enum-not-error.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Other { message: String },
|
||||
}
|
||||
|
||||
fn main() {}
|
23
vendor/thiserror/tests/ui/transparent-enum-not-error.stderr
vendored
Normal file
23
vendor/thiserror/tests/ui/transparent-enum-not-error.stderr
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied
|
||||
--> tests/ui/transparent-enum-not-error.rs:5:13
|
||||
|
|
||||
5 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds
|
||||
|
|
||||
::: $RUST/alloc/src/string.rs
|
||||
|
|
||||
| pub struct String {
|
||||
| -----------------
|
||||
| |
|
||||
| doesn't satisfy `String: AsDynError<'_>`
|
||||
| doesn't satisfy `String: std::error::Error`
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`String: std::error::Error`
|
||||
which is required by `String: AsDynError<'_>`
|
||||
`&String: std::error::Error`
|
||||
which is required by `&String: AsDynError<'_>`
|
||||
`str: Sized`
|
||||
which is required by `str: AsDynError<'_>`
|
||||
`str: std::error::Error`
|
||||
which is required by `str: AsDynError<'_>`
|
9
vendor/thiserror/tests/ui/transparent-enum-source.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/transparent-enum-source.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Other(#[source] anyhow::Error),
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/transparent-enum-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/transparent-enum-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: transparent variant can't contain #[source]
|
||||
--> tests/ui/transparent-enum-source.rs:6:11
|
||||
|
|
||||
6 | Other(#[source] anyhow::Error),
|
||||
| ^^^^^^^^^
|
9
vendor/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error(transparent)]
|
||||
Other(String),
|
||||
}
|
||||
|
||||
fn main() {}
|
23
vendor/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr
vendored
Normal file
23
vendor/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its trait bounds were not satisfied
|
||||
--> tests/ui/transparent-enum-unnamed-field-not-error.rs:5:13
|
||||
|
|
||||
5 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^ method cannot be called on `&String` due to unsatisfied trait bounds
|
||||
|
|
||||
::: $RUST/alloc/src/string.rs
|
||||
|
|
||||
| pub struct String {
|
||||
| -----------------
|
||||
| |
|
||||
| doesn't satisfy `String: AsDynError<'_>`
|
||||
| doesn't satisfy `String: std::error::Error`
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`String: std::error::Error`
|
||||
which is required by `String: AsDynError<'_>`
|
||||
`&String: std::error::Error`
|
||||
which is required by `&String: AsDynError<'_>`
|
||||
`str: Sized`
|
||||
which is required by `str: AsDynError<'_>`
|
||||
`str: std::error::Error`
|
||||
which is required by `str: AsDynError<'_>`
|
10
vendor/thiserror/tests/ui/transparent-struct-many.rs
vendored
Normal file
10
vendor/thiserror/tests/ui/transparent-struct-many.rs
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct Error {
|
||||
inner: anyhow::Error,
|
||||
what: String,
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/transparent-struct-many.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/transparent-struct-many.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: #[error(transparent)] requires exactly one field
|
||||
--> tests/ui/transparent-struct-many.rs:4:1
|
||||
|
|
||||
4 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
9
vendor/thiserror/tests/ui/transparent-struct-not-error.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/transparent-struct-not-error.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct Error {
|
||||
message: String,
|
||||
}
|
||||
|
||||
fn main() {}
|
21
vendor/thiserror/tests/ui/transparent-struct-not-error.stderr
vendored
Normal file
21
vendor/thiserror/tests/ui/transparent-struct-not-error.stderr
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied
|
||||
--> tests/ui/transparent-struct-not-error.rs:4:9
|
||||
|
|
||||
4 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds
|
||||
|
|
||||
::: $RUST/alloc/src/string.rs
|
||||
|
|
||||
| pub struct String {
|
||||
| -----------------
|
||||
| |
|
||||
| doesn't satisfy `String: AsDynError<'_>`
|
||||
| doesn't satisfy `String: std::error::Error`
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`String: std::error::Error`
|
||||
which is required by `String: AsDynError<'_>`
|
||||
`str: Sized`
|
||||
which is required by `str: AsDynError<'_>`
|
||||
`str: std::error::Error`
|
||||
which is required by `str: AsDynError<'_>`
|
7
vendor/thiserror/tests/ui/transparent-struct-source.rs
vendored
Normal file
7
vendor/thiserror/tests/ui/transparent-struct-source.rs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct Error(#[source] anyhow::Error);
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/transparent-struct-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/transparent-struct-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: transparent error struct can't contain #[source]
|
||||
--> tests/ui/transparent-struct-source.rs:5:18
|
||||
|
|
||||
5 | pub struct Error(#[source] anyhow::Error);
|
||||
| ^^^^^^^^^
|
7
vendor/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs
vendored
Normal file
7
vendor/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.rs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error(transparent)]
|
||||
pub struct Error(String);
|
||||
|
||||
fn main() {}
|
21
vendor/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr
vendored
Normal file
21
vendor/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trait bounds were not satisfied
|
||||
--> tests/ui/transparent-struct-unnamed-field-not-error.rs:4:9
|
||||
|
|
||||
4 | #[error(transparent)]
|
||||
| ^^^^^^^^^^^ method cannot be called on `String` due to unsatisfied trait bounds
|
||||
|
|
||||
::: $RUST/alloc/src/string.rs
|
||||
|
|
||||
| pub struct String {
|
||||
| -----------------
|
||||
| |
|
||||
| doesn't satisfy `String: AsDynError<'_>`
|
||||
| doesn't satisfy `String: std::error::Error`
|
||||
|
|
||||
= note: the following trait bounds were not satisfied:
|
||||
`String: std::error::Error`
|
||||
which is required by `String: AsDynError<'_>`
|
||||
`str: Sized`
|
||||
which is required by `str: AsDynError<'_>`
|
||||
`str: std::error::Error`
|
||||
which is required by `str: AsDynError<'_>`
|
11
vendor/thiserror/tests/ui/unexpected-field-fmt.rs
vendored
Normal file
11
vendor/thiserror/tests/ui/unexpected-field-fmt.rs
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
What {
|
||||
#[error("...")]
|
||||
io: std::io::Error,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/unexpected-field-fmt.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/unexpected-field-fmt.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: not expected here; the #[error(...)] attribute belongs on top of a struct or an enum variant
|
||||
--> tests/ui/unexpected-field-fmt.rs:6:9
|
||||
|
|
||||
6 | #[error("...")]
|
||||
| ^^^^^^^^^^^^^^^
|
7
vendor/thiserror/tests/ui/unexpected-struct-source.rs
vendored
Normal file
7
vendor/thiserror/tests/ui/unexpected-struct-source.rs
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[source]
|
||||
pub struct Error;
|
||||
|
||||
fn main() {}
|
5
vendor/thiserror/tests/ui/unexpected-struct-source.stderr
vendored
Normal file
5
vendor/thiserror/tests/ui/unexpected-struct-source.stderr
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
error: not expected here; the #[source] attribute belongs on a specific field
|
||||
--> tests/ui/unexpected-struct-source.rs:4:1
|
||||
|
|
||||
4 | #[source]
|
||||
| ^^^^^^^^^
|
9
vendor/thiserror/tests/ui/union.rs
vendored
Normal file
9
vendor/thiserror/tests/ui/union.rs
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error)]
|
||||
pub union U {
|
||||
msg: &'static str,
|
||||
num: usize,
|
||||
}
|
||||
|
||||
fn main() {}
|
8
vendor/thiserror/tests/ui/union.stderr
vendored
Normal file
8
vendor/thiserror/tests/ui/union.stderr
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
error: union as errors are not supported
|
||||
--> tests/ui/union.rs:4:1
|
||||
|
|
||||
4 | / pub union U {
|
||||
5 | | msg: &'static str,
|
||||
6 | | num: usize,
|
||||
7 | | }
|
||||
| |_^
|
Reference in New Issue
Block a user