aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeff Vander Stoep <jeffv@google.com>2023-01-17 22:30:32 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-01-17 22:30:32 +0000
commit326cc2846982db68378188b135a57a1e2e4eb6a0 (patch)
tree74b35f25c2bf55ab1f00fac536a6a972dbfaead7 /tests
parentfe6dce880f9fece5a99e477c9214a58dd9d96f86 (diff)
parent7d05dd2f2cfeb736dbdbf659634e56e1b4e5e7e0 (diff)
downloadanyhow-326cc2846982db68378188b135a57a1e2e4eb6a0.tar.gz
Upgrade anyhow to 1.0.68 am: 85b5e2f6c5 am: 1cc8d7544c am: 7d05dd2f2c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/anyhow/+/2391492 Change-Id: Ie1e2789848b1bd24e32408793058dbe5ba370e43 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_downcast.rs2
-rw-r--r--tests/test_ensure.rs42
-rw-r--r--tests/test_macros.rs1
-rw-r--r--tests/ui/empty-ensure.stderr7
-rw-r--r--tests/ui/must-use.stderr2
-rw-r--r--tests/ui/no-impl.stderr69
-rw-r--r--tests/ui/temporary-value.stderr2
7 files changed, 70 insertions, 55 deletions
diff --git a/tests/test_downcast.rs b/tests/test_downcast.rs
index 7fb063f..b4470d5 100644
--- a/tests/test_downcast.rs
+++ b/tests/test_downcast.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::wildcard_imports)]
+#![allow(clippy::assertions_on_result_states, clippy::wildcard_imports)]
mod common;
mod drop;
diff --git a/tests/test_ensure.rs b/tests/test_ensure.rs
index 4bb12f9..de867f7 100644
--- a/tests/test_ensure.rs
+++ b/tests/test_ensure.rs
@@ -1,13 +1,13 @@
#![allow(
+ clippy::bool_to_int_with_if,
clippy::diverging_sub_expression,
clippy::if_same_then_else,
clippy::ifs_same_cond,
clippy::items_after_statements,
clippy::let_and_return,
- clippy::let_underscore_drop,
- clippy::logic_bug,
clippy::match_bool,
clippy::never_loop,
+ clippy::overly_complex_bool_expr,
clippy::redundant_closure_call,
clippy::redundant_pattern_matching,
clippy::too_many_lines,
@@ -17,10 +17,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 +45,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 +375,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 +428,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 +616,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/tests/test_macros.rs b/tests/test_macros.rs
index 1ac3970..a3342ab 100644
--- a/tests/test_macros.rs
+++ b/tests/test_macros.rs
@@ -1,4 +1,5 @@
#![allow(
+ clippy::assertions_on_result_states,
clippy::eq_op,
clippy::items_after_statements,
clippy::needless_pass_by_value,
diff --git a/tests/ui/empty-ensure.stderr b/tests/ui/empty-ensure.stderr
index b500de9..bf0229a 100644
--- a/tests/ui/empty-ensure.stderr
+++ b/tests/ui/empty-ensure.stderr
@@ -4,4 +4,9 @@ error: unexpected end of macro invocation
4 | ensure!();
| ^^^^^^^^^ missing tokens in macro arguments
|
- = note: this error originates in the macro `$crate::__parse_ensure` (in Nightly builds, run with -Z macro-backtrace for more info)
+note: while trying to match meta-variable `$cond:expr`
+ --> src/ensure.rs
+ |
+ | ($cond:expr $(,)?) => {
+ | ^^^^^^^^^^
+ = note: this error originates in the macro `$crate::__parse_ensure` which comes from the expansion of the macro `ensure` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/must-use.stderr b/tests/ui/must-use.stderr
index e9ee24b..e10bde4 100644
--- a/tests/ui/must-use.stderr
+++ b/tests/ui/must-use.stderr
@@ -1,4 +1,4 @@
-error: unused return value of `anyhow::private::must_use` that must be used
+error: unused return value of `anyhow::__private::must_use` that must be used
--> tests/ui/must-use.rs:8:9
|
8 | anyhow!("it failed");
diff --git a/tests/ui/no-impl.stderr b/tests/ui/no-impl.stderr
index 02ab494..1ddf768 100644
--- a/tests/ui/no-impl.stderr
+++ b/tests/ui/no-impl.stderr
@@ -1,42 +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::private::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::private::kind::TraitKind`
- `Error: std::fmt::Display`
- which is required by `&Error: anyhow::private::kind::AdhocKind`
- `&Error: Into<anyhow::Error>`
- which is required by `&Error: anyhow::private::kind::TraitKind`
-note: the following traits must be implemented
- --> $RUST/core/src/convert/mod.rs
- |
- | / pub trait Into<T>: Sized {
- | | /// Converts this type into the (usually inferred) input type.
- | | #[must_use]
- | | #[stable(feature = "rust1", since = "1.0.0")]
- | | fn into(self) -> T;
- | | }
- | |_^
- |
- ::: $RUST/core/src/fmt/mod.rs
- |
- | / pub trait Display {
- | | /// Formats the value using the given formatter.
- | | ///
- | | /// # Examples
-... |
- | | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
- | | }
- | |_^
- = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info)
+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 traits `Into` and `std::fmt::Display` 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)
diff --git a/tests/ui/temporary-value.stderr b/tests/ui/temporary-value.stderr
index 4e4115f..dc27c49 100644
--- a/tests/ui/temporary-value.stderr
+++ b/tests/ui/temporary-value.stderr
@@ -4,6 +4,6 @@ error[E0716]: temporary value dropped while borrowed
4 | let _ = anyhow!(&String::new());
| ---------^^^^^^^^^^^^^-
| | |
- | | creates a temporary which is freed while still in use
+ | | creates a temporary value which is freed while still in use
| temporary value is freed at the end of this statement
| argument requires that borrow lasts for `'static`