From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- vendor/anyhow/tests/test_ensure.rs | 39 +++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'vendor/anyhow/tests/test_ensure.rs') 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 Trait for T {} +enum Enum { + #[allow(dead_code)] + Thing(PhantomData), + Generic, +} + +impl PartialEq for Enum { + fn eq(&self, rhs: &Self) -> bool { + mem::discriminant(self) == mem::discriminant(rhs) + } +} + +impl Debug for Enum { + fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("Generic") + } +} + #[track_caller] fn assert_err(result: impl FnOnce() -> Result, expected: &'static str) { let actual = result().unwrap_err().to_string(); @@ -355,27 +376,27 @@ fn test_path() { let test = || Ok(ensure!(E::U::>E::U)); assert_err(test, "Condition failed: `E::U:: > E::U` (U vs U)"); - let test = || Ok(ensure!(PhantomData:: != PhantomData)); + let test = || Ok(ensure!(Generic:: != Generic)); assert_err( test, - "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic:: != Generic` (Generic vs Generic)", ); - let test = || Ok(ensure!(PhantomData:: != PhantomData)); + let test = || Ok(ensure!(Generic:: != Generic)); assert_err( test, - "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic:: != Generic` (Generic vs Generic)", ); #[rustfmt::skip] let test = || { Ok(ensure!( - PhantomData:: != PhantomData + Generic:: != Generic )) }; assert_err( test, - "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `Generic:: != Generic` (Generic vs Generic)", ); } @@ -408,7 +429,7 @@ fn test_trailer() { let test = || Ok(ensure!(PhantomData:: {} != PhantomData)); assert_err( test, - "Condition failed: `PhantomData:: {} != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `PhantomData:: {} != PhantomData` (PhantomData vs PhantomData)", ); let result = Ok::<_, Error>(1); @@ -596,7 +617,7 @@ fn test_as() { }; assert_err( test, - "Condition failed: `PhantomData as PhantomData<::Owned> != PhantomData` (PhantomData vs PhantomData)", + "Condition failed: `PhantomData as PhantomData<::Owned> != PhantomData` (PhantomData vs PhantomData)", ); macro_rules! int { -- cgit v1.2.3