diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /vendor/thiserror/tests | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/thiserror/tests/compiletest.rs | 3 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_backtrace.rs | 85 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_deprecated.rs | 10 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_display.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_error.rs | 1 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_expr.rs | 3 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_from.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_generics.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_option.rs | 6 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_path.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_source.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/test_transparent.rs | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/concat-display.stderr | 2 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/from-backtrace-backtrace.rs | 10 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr | 5 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/no-display.stderr | 12 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/source-enum-not-error.stderr | 44 | ||||
-rw-r--r-- | vendor/thiserror/tests/ui/source-struct-not-error.stderr | 42 |
18 files changed, 140 insertions, 95 deletions
diff --git a/vendor/thiserror/tests/compiletest.rs b/vendor/thiserror/tests/compiletest.rs index 641d03cbf..7974a6249 100644 --- a/vendor/thiserror/tests/compiletest.rs +++ b/vendor/thiserror/tests/compiletest.rs @@ -1,6 +1,5 @@ -#![deny(clippy::all, clippy::pedantic)] - #[rustversion::attr(not(nightly), ignore)] +#[cfg_attr(miri, ignore)] #[test] fn ui() { let t = trybuild::TestCases::new(); diff --git a/vendor/thiserror/tests/test_backtrace.rs b/vendor/thiserror/tests/test_backtrace.rs index 42e37ca16..43f68b8b7 100644 --- a/vendor/thiserror/tests/test_backtrace.rs +++ b/vendor/thiserror/tests/test_backtrace.rs @@ -1,4 +1,7 @@ -#![cfg_attr(thiserror_nightly_testing, feature(backtrace))] +#![cfg_attr( + thiserror_nightly_testing, + feature(error_generic_member_access, provide_any) +)] use thiserror::Error; @@ -16,6 +19,7 @@ pub struct InnerBacktrace { #[cfg(thiserror_nightly_testing)] pub mod structs { use super::{Inner, InnerBacktrace}; + use std::any; use std::backtrace::Backtrace; use std::error::Error; use std::sync::Arc; @@ -83,49 +87,94 @@ pub mod structs { 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.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ExplicitBacktrace { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktrace { backtrace: Some(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktrace { backtrace: Arc::new(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); + + let error = AnyhowBacktrace { + source: anyhow::Error::msg("..."), + }; + assert!(any::request_ref::<Backtrace>(&error).is_some()); + + let error = BoxDynErrorBacktrace { + source: Box::new(PlainBacktrace { + backtrace: Backtrace::capture(), + }), + }; + assert!(any::request_ref::<Backtrace>(&error).is_some()); + } + + // https://github.com/dtolnay/thiserror/issues/185 -- std::error::Error and + // std::any::Provide both have a method called 'provide', so directly + // calling it from generated code could be ambiguous. + #[test] + fn test_provide_name_collision() { + use std::any::Provider; + + #[derive(Error, Debug)] + #[error("...")] + struct MyError { + #[source] + #[backtrace] + x: std::io::Error, + } + + let _: dyn Error; + let _: dyn Provider; } } #[cfg(thiserror_nightly_testing)] pub mod enums { use super::{Inner, InnerBacktrace}; + use std::any; use std::backtrace::Backtrace; - use std::error::Error; use std::sync::Arc; use thiserror::Error; @@ -210,36 +259,36 @@ pub mod enums { let error = PlainBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ExplicitBacktrace::Test { backtrace: Backtrace::capture(), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktrace::Test { backtrace: Some(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktrace::Test { backtrace: Arc::new(Backtrace::capture()), }; - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = BacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = CombinedBacktraceFrom::from(InnerBacktrace { backtrace: Backtrace::capture(), }); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = OptBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); let error = ArcBacktraceFrom::from(Inner); - assert!(error.backtrace().is_some()); + assert!(any::request_ref::<Backtrace>(&error).is_some()); } } diff --git a/vendor/thiserror/tests/test_deprecated.rs b/vendor/thiserror/tests/test_deprecated.rs new file mode 100644 index 000000000..5524666ab --- /dev/null +++ b/vendor/thiserror/tests/test_deprecated.rs @@ -0,0 +1,10 @@ +#![deny(deprecated, clippy::all, clippy::pedantic)] + +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum Error { + #[deprecated] + #[error("...")] + Deprecated, +} diff --git a/vendor/thiserror/tests/test_display.rs b/vendor/thiserror/tests/test_display.rs index 949d9eda7..8917bb054 100644 --- a/vendor/thiserror/tests/test_display.rs +++ b/vendor/thiserror/tests/test_display.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::fmt::Display; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_error.rs b/vendor/thiserror/tests/test_error.rs index ece7f91a9..fab934d78 100644 --- a/vendor/thiserror/tests/test_error.rs +++ b/vendor/thiserror/tests/test_error.rs @@ -1,4 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] #![allow(dead_code)] use std::fmt::{self, Display}; diff --git a/vendor/thiserror/tests/test_expr.rs b/vendor/thiserror/tests/test_expr.rs index 87a56cf58..34de56087 100644 --- a/vendor/thiserror/tests/test_expr.rs +++ b/vendor/thiserror/tests/test_expr.rs @@ -1,5 +1,4 @@ -#![deny(clippy::all, clippy::pedantic)] -#![allow(clippy::option_if_let_else)] +#![allow(clippy::iter_cloned_collect, clippy::option_if_let_else)] use std::fmt::Display; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_from.rs b/vendor/thiserror/tests/test_from.rs index a25ce353d..1f387055f 100644 --- a/vendor/thiserror/tests/test_from.rs +++ b/vendor/thiserror/tests/test_from.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::io; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_generics.rs b/vendor/thiserror/tests/test_generics.rs index f5e1de243..4ab9f3778 100644 --- a/vendor/thiserror/tests/test_generics.rs +++ b/vendor/thiserror/tests/test_generics.rs @@ -1,4 +1,4 @@ -#![deny(clippy::all, clippy::pedantic)] +#![allow(clippy::needless_late_init)] use std::fmt::{self, Debug, Display}; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_option.rs b/vendor/thiserror/tests/test_option.rs index ca2171385..ed5287dc9 100644 --- a/vendor/thiserror/tests/test_option.rs +++ b/vendor/thiserror/tests/test_option.rs @@ -1,5 +1,7 @@ -#![cfg_attr(thiserror_nightly_testing, feature(backtrace))] -#![deny(clippy::all, clippy::pedantic)] +#![cfg_attr( + thiserror_nightly_testing, + feature(error_generic_member_access, provide_any) +)] #[cfg(thiserror_nightly_testing)] pub mod structs { diff --git a/vendor/thiserror/tests/test_path.rs b/vendor/thiserror/tests/test_path.rs index a10b1f342..a34a3d74e 100644 --- a/vendor/thiserror/tests/test_path.rs +++ b/vendor/thiserror/tests/test_path.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use ref_cast::RefCast; use std::fmt::Display; use std::path::{Path, PathBuf}; diff --git a/vendor/thiserror/tests/test_source.rs b/vendor/thiserror/tests/test_source.rs index ab16097b2..637f4ac0a 100644 --- a/vendor/thiserror/tests/test_source.rs +++ b/vendor/thiserror/tests/test_source.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use std::error::Error as StdError; use std::io; use thiserror::Error; diff --git a/vendor/thiserror/tests/test_transparent.rs b/vendor/thiserror/tests/test_transparent.rs index 84d7c9189..6f3c03ec7 100644 --- a/vendor/thiserror/tests/test_transparent.rs +++ b/vendor/thiserror/tests/test_transparent.rs @@ -1,5 +1,3 @@ -#![deny(clippy::all, clippy::pedantic)] - use anyhow::anyhow; use std::error::Error as _; use std::io; diff --git a/vendor/thiserror/tests/ui/concat-display.stderr b/vendor/thiserror/tests/ui/concat-display.stderr index 6ab40481f..dbecd69f2 100644 --- a/vendor/thiserror/tests/ui/concat-display.stderr +++ b/vendor/thiserror/tests/ui/concat-display.stderr @@ -5,6 +5,6 @@ error: expected string literal | ^^^^^^ ... 13 | error_type!(Error, "foo"); - | -------------------------- in this macro invocation + | ------------------------- in this macro invocation | = note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs b/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs new file mode 100644 index 000000000..8f411bf5d --- /dev/null +++ b/vendor/thiserror/tests/ui/from-backtrace-backtrace.rs @@ -0,0 +1,10 @@ +// 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() {} diff --git a/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr b/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr new file mode 100644 index 000000000..55d647b42 --- /dev/null +++ b/vendor/thiserror/tests/ui/from-backtrace-backtrace.stderr @@ -0,0 +1,5 @@ +error: deriving From requires no fields other than source and backtrace + --> tests/ui/from-backtrace-backtrace.rs:8:18 + | +8 | pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace); + | ^^^^^^^ diff --git a/vendor/thiserror/tests/ui/no-display.stderr b/vendor/thiserror/tests/ui/no-display.stderr index e6a52f5e7..82c3eea1c 100644 --- a/vendor/thiserror/tests/ui/no-display.stderr +++ b/vendor/thiserror/tests/ui/no-display.stderr @@ -2,7 +2,7 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its --> tests/ui/no-display.rs:7:9 | 4 | struct NoDisplay; - | ----------------- doesn't satisfy `NoDisplay: std::fmt::Display` + | ---------------- doesn't satisfy `NoDisplay: std::fmt::Display` ... 7 | #[error("thread: {thread}")] | ^^^^^^^^^^^^^^^^^^ method cannot be called on `&NoDisplay` due to unsatisfied trait bounds @@ -13,11 +13,5 @@ error[E0599]: the method `as_display` exists for reference `&NoDisplay`, but its note: the following trait must be implemented --> $RUST/core/src/fmt/mod.rs | - | / pub trait Display { - | | /// Formats the value using the given formatter. - | | /// - | | /// # Examples -... | - | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; - | | } - | |_^ + | pub trait Display { + | ^^^^^^^^^^^^^^^^^ diff --git a/vendor/thiserror/tests/ui/source-enum-not-error.stderr b/vendor/thiserror/tests/ui/source-enum-not-error.stderr index d01cba5b0..29ee54600 100644 --- a/vendor/thiserror/tests/ui/source-enum-not-error.stderr +++ b/vendor/thiserror/tests/ui/source-enum-not-error.stderr @@ -1,28 +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:10:9 - | -4 | pub struct NotError; - | -------------------- - | | - | doesn't satisfy `NotError: AsDynError` - | doesn't satisfy `NotError: std::error::Error` + --> tests/ui/source-enum-not-error.rs:10:9 + | +4 | pub struct NotError; + | ------------------- + | | + | doesn't satisfy `NotError: AsDynError<'_>` + | doesn't satisfy `NotError: std::error::Error` ... -10 | 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` +10 | 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 following trait must be implemented - --> $RUST/std/src/error.rs - | - | / pub trait Error: Debug + Display { - | | /// The lower-level source of this error, if any. - | | /// - | | /// # Examples -... | - | | } - | | } - | |_^ + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/vendor/thiserror/tests/ui/source-struct-not-error.stderr b/vendor/thiserror/tests/ui/source-struct-not-error.stderr index be1331a50..efa40281d 100644 --- a/vendor/thiserror/tests/ui/source-struct-not-error.stderr +++ b/vendor/thiserror/tests/ui/source-struct-not-error.stderr @@ -1,27 +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 - | doesn't satisfy `NotError: AsDynError` - | doesn't satisfy `NotError: std::error::Error` + --> 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` +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 following trait must be implemented - --> $RUST/std/src/error.rs - | - | / pub trait Error: Debug + Display { - | | /// The lower-level source of this error, if any. - | | /// - | | /// # Examples -... | - | | } - | | } - | |_^ + --> $RUST/core/src/error.rs + | + | pub trait Error: Debug + Display { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |