diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:58 +0000 |
commit | a4b7ed7a42c716ab9f05e351f003d589124fd55d (patch) | |
tree | b620cd3f223850b28716e474e80c58059dca5dd4 /vendor/anyhow/tests | |
parent | Adding upstream version 1.67.1+dfsg1. (diff) | |
download | rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip |
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anyhow/tests')
-rw-r--r-- | vendor/anyhow/tests/test_ensure.rs | 39 | ||||
-rw-r--r-- | vendor/anyhow/tests/ui/no-impl.stderr | 56 |
2 files changed, 58 insertions, 37 deletions
diff --git a/vendor/anyhow/tests/test_ensure.rs b/vendor/anyhow/tests/test_ensure.rs index cbcba5798..6984c7d11 100644 --- a/vendor/anyhow/tests/test_ensure.rs +++ b/vendor/anyhow/tests/test_ensure.rs @@ -1,4 +1,5 @@ #![allow( + clippy::bool_to_int_with_if, clippy::diverging_sub_expression, clippy::if_same_then_else, clippy::ifs_same_cond, @@ -17,10 +18,12 @@ irrefutable_let_patterns )] +use self::Enum::Generic; use anyhow::{anyhow, ensure, Chain, Error, Result}; -use std::fmt::Debug; +use std::fmt::{self, Debug}; use std::iter; use std::marker::{PhantomData, PhantomData as P}; +use std::mem; use std::ops::Add; use std::ptr; @@ -43,6 +46,24 @@ trait Trait: Sized { impl<T> Trait for T {} +enum Enum<T: ?Sized> { + #[allow(dead_code)] + Thing(PhantomData<T>), + Generic, +} + +impl<T: ?Sized> PartialEq for Enum<T> { + fn eq(&self, rhs: &Self) -> bool { + mem::discriminant(self) == mem::discriminant(rhs) + } +} + +impl<T: ?Sized> Debug for Enum<T> { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Generic") + } +} + #[track_caller] fn assert_err<T: Debug>(result: impl FnOnce() -> Result<T>, expected: &'static str) { let actual = result().unwrap_err().to_string(); @@ -355,27 +376,27 @@ fn test_path() { let test = || Ok(ensure!(E::U::<u8,>>E::U)); assert_err(test, "Condition failed: `E::U::<u8> > E::U` (U vs U)"); - let test = || Ok(ensure!(PhantomData::<dyn Debug + Sync> != PhantomData)); + let test = || Ok(ensure!(Generic::<dyn Debug + Sync> != Generic)); assert_err( test, - "Condition failed: `PhantomData::<dyn Debug + Sync> != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic::<dyn Debug + Sync> != Generic` (Generic vs Generic)", ); - let test = || Ok(ensure!(PhantomData::<dyn Fn() + Sync> != PhantomData)); + let test = || Ok(ensure!(Generic::<dyn Fn() + Sync> != Generic)); assert_err( test, - "Condition failed: `PhantomData::<dyn Fn() + Sync> != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic::<dyn Fn() + Sync> != Generic` (Generic vs Generic)", ); #[rustfmt::skip] let test = || { Ok(ensure!( - PhantomData::<dyn Fn::() + ::std::marker::Sync> != PhantomData + Generic::<dyn Fn::() + ::std::marker::Sync> != Generic )) }; assert_err( test, - "Condition failed: `PhantomData::<dyn Fn() + ::std::marker::Sync> != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic::<dyn Fn() + ::std::marker::Sync> != Generic` (Generic vs Generic)", ); } @@ -408,7 +429,7 @@ fn test_trailer() { let test = || Ok(ensure!(PhantomData::<u8> {} != PhantomData)); assert_err( test, - "Condition failed: `PhantomData::<u8> {} != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `PhantomData::<u8> {} != PhantomData` (PhantomData<u8> vs PhantomData<u8>)", ); let result = Ok::<_, Error>(1); @@ -596,7 +617,7 @@ fn test_as() { }; assert_err( test, - "Condition failed: `PhantomData as PhantomData<<i32 as ToOwned>::Owned> != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `PhantomData as PhantomData<<i32 as ToOwned>::Owned> != PhantomData` (PhantomData<i32> vs PhantomData<i32>)", ); macro_rules! int { diff --git a/vendor/anyhow/tests/ui/no-impl.stderr b/vendor/anyhow/tests/ui/no-impl.stderr index 074dafe62..dced9987e 100644 --- a/vendor/anyhow/tests/ui/no-impl.stderr +++ b/vendor/anyhow/tests/ui/no-impl.stderr @@ -1,31 +1,31 @@ error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied - --> tests/ui/no-impl.rs:7:13 - | -4 | struct Error; - | ------------ - | | - | doesn't satisfy `Error: Into<anyhow::Error>` - | doesn't satisfy `Error: anyhow::kind::TraitKind` - | doesn't satisfy `Error: std::fmt::Display` + --> tests/ui/no-impl.rs:7:13 + | +4 | struct Error; + | ------------ + | | + | doesn't satisfy `Error: Into<anyhow::Error>` + | doesn't satisfy `Error: anyhow::kind::TraitKind` + | doesn't satisfy `Error: std::fmt::Display` ... -7 | let _ = anyhow!(Error); - | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `Error: Into<anyhow::Error>` - which is required by `Error: anyhow::kind::TraitKind` - `Error: std::fmt::Display` - which is required by `&Error: anyhow::kind::AdhocKind` - `&Error: Into<anyhow::Error>` - which is required by `&Error: anyhow::kind::TraitKind` +7 | let _ = anyhow!(Error); + | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `Error: Into<anyhow::Error>` + which is required by `Error: anyhow::kind::TraitKind` + `Error: std::fmt::Display` + which is required by `&Error: anyhow::kind::AdhocKind` + `&Error: Into<anyhow::Error>` + which is required by `&Error: anyhow::kind::TraitKind` note: the following traits must be implemented - --> $RUST/core/src/fmt/mod.rs - | - | pub trait Display { - | ^^^^^^^^^^^^^^^^^ - | - ::: $RUST/core/src/convert/mod.rs - | - | pub trait Into<T>: Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) + --> $RUST/core/src/fmt/mod.rs + | + | pub trait Display { + | ^^^^^^^^^^^^^^^^^ + | + ::: $RUST/core/src/convert/mod.rs + | + | pub trait Into<T>: Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) |