summaryrefslogtreecommitdiffstats
path: root/vendor/anyhow/tests/ui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/anyhow/tests/ui
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/anyhow/tests/ui')
-rw-r--r--vendor/anyhow/tests/ui/chained-comparison.rs8
-rw-r--r--vendor/anyhow/tests/ui/chained-comparison.stderr10
-rw-r--r--vendor/anyhow/tests/ui/empty-ensure.rs6
-rw-r--r--vendor/anyhow/tests/ui/empty-ensure.stderr7
-rw-r--r--vendor/anyhow/tests/ui/must-use.rs11
-rw-r--r--vendor/anyhow/tests/ui/must-use.stderr12
-rw-r--r--vendor/anyhow/tests/ui/no-impl.rs8
-rw-r--r--vendor/anyhow/tests/ui/no-impl.stderr31
-rw-r--r--vendor/anyhow/tests/ui/temporary-value.rs5
-rw-r--r--vendor/anyhow/tests/ui/temporary-value.stderr9
-rw-r--r--vendor/anyhow/tests/ui/wrong-interpolation.rs5
-rw-r--r--vendor/anyhow/tests/ui/wrong-interpolation.stderr5
12 files changed, 117 insertions, 0 deletions
diff --git a/vendor/anyhow/tests/ui/chained-comparison.rs b/vendor/anyhow/tests/ui/chained-comparison.rs
new file mode 100644
index 000000000..4521b51c8
--- /dev/null
+++ b/vendor/anyhow/tests/ui/chained-comparison.rs
@@ -0,0 +1,8 @@
+use anyhow::{ensure, Result};
+
+fn main() -> Result<()> {
+ // `ensure!` must not partition this into `(false) == (false == true)`
+ // because Rust doesn't ordinarily allow this form of expression.
+ ensure!(false == false == true);
+ Ok(())
+}
diff --git a/vendor/anyhow/tests/ui/chained-comparison.stderr b/vendor/anyhow/tests/ui/chained-comparison.stderr
new file mode 100644
index 000000000..2a4c66508
--- /dev/null
+++ b/vendor/anyhow/tests/ui/chained-comparison.stderr
@@ -0,0 +1,10 @@
+error: comparison operators cannot be chained
+ --> tests/ui/chained-comparison.rs:6:19
+ |
+6 | ensure!(false == false == true);
+ | ^^ ^^
+ |
+help: split the comparison into two
+ |
+6 | ensure!(false == false && false == true);
+ | ++++++++
diff --git a/vendor/anyhow/tests/ui/empty-ensure.rs b/vendor/anyhow/tests/ui/empty-ensure.rs
new file mode 100644
index 000000000..139b743bb
--- /dev/null
+++ b/vendor/anyhow/tests/ui/empty-ensure.rs
@@ -0,0 +1,6 @@
+use anyhow::{ensure, Result};
+
+fn main() -> Result<()> {
+ ensure!();
+ Ok(())
+}
diff --git a/vendor/anyhow/tests/ui/empty-ensure.stderr b/vendor/anyhow/tests/ui/empty-ensure.stderr
new file mode 100644
index 000000000..91e0a9803
--- /dev/null
+++ b/vendor/anyhow/tests/ui/empty-ensure.stderr
@@ -0,0 +1,7 @@
+error: unexpected end of macro invocation
+ --> tests/ui/empty-ensure.rs:4:5
+ |
+4 | ensure!();
+ | ^^^^^^^^^ missing tokens in macro arguments
+ |
+ = 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/vendor/anyhow/tests/ui/must-use.rs b/vendor/anyhow/tests/ui/must-use.rs
new file mode 100644
index 000000000..ea4e58f55
--- /dev/null
+++ b/vendor/anyhow/tests/ui/must-use.rs
@@ -0,0 +1,11 @@
+#![deny(unused_must_use)]
+
+use anyhow::anyhow;
+
+fn main() -> anyhow::Result<()> {
+ if true {
+ // meant to write bail!
+ anyhow!("it failed");
+ }
+ Ok(())
+}
diff --git a/vendor/anyhow/tests/ui/must-use.stderr b/vendor/anyhow/tests/ui/must-use.stderr
new file mode 100644
index 000000000..e9ee24b09
--- /dev/null
+++ b/vendor/anyhow/tests/ui/must-use.stderr
@@ -0,0 +1,12 @@
+error: unused return value of `anyhow::private::must_use` that must be used
+ --> tests/ui/must-use.rs:8:9
+ |
+8 | anyhow!("it failed");
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+note: the lint level is defined here
+ --> tests/ui/must-use.rs:1:9
+ |
+1 | #![deny(unused_must_use)]
+ | ^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/anyhow/tests/ui/no-impl.rs b/vendor/anyhow/tests/ui/no-impl.rs
new file mode 100644
index 000000000..d2e89afc1
--- /dev/null
+++ b/vendor/anyhow/tests/ui/no-impl.rs
@@ -0,0 +1,8 @@
+use anyhow::anyhow;
+
+#[derive(Debug)]
+struct Error;
+
+fn main() {
+ let _ = anyhow!(Error);
+}
diff --git a/vendor/anyhow/tests/ui/no-impl.stderr b/vendor/anyhow/tests/ui/no-impl.stderr
new file mode 100644
index 000000000..7c5ec503f
--- /dev/null
+++ b/vendor/anyhow/tests/ui/no-impl.stderr
@@ -0,0 +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`
+...
+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/convert/mod.rs
+ |
+ | pub trait Into<T>: Sized {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ ::: $RUST/core/src/fmt/mod.rs
+ |
+ | pub trait Display {
+ | ^^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/anyhow/tests/ui/temporary-value.rs b/vendor/anyhow/tests/ui/temporary-value.rs
new file mode 100644
index 000000000..803809b23
--- /dev/null
+++ b/vendor/anyhow/tests/ui/temporary-value.rs
@@ -0,0 +1,5 @@
+use anyhow::anyhow;
+
+fn main() {
+ let _ = anyhow!(&String::new());
+}
diff --git a/vendor/anyhow/tests/ui/temporary-value.stderr b/vendor/anyhow/tests/ui/temporary-value.stderr
new file mode 100644
index 000000000..4e4115fc3
--- /dev/null
+++ b/vendor/anyhow/tests/ui/temporary-value.stderr
@@ -0,0 +1,9 @@
+error[E0716]: temporary value dropped while borrowed
+ --> tests/ui/temporary-value.rs:4:22
+ |
+4 | let _ = anyhow!(&String::new());
+ | ---------^^^^^^^^^^^^^-
+ | | |
+ | | creates a temporary which is freed while still in use
+ | temporary value is freed at the end of this statement
+ | argument requires that borrow lasts for `'static`
diff --git a/vendor/anyhow/tests/ui/wrong-interpolation.rs b/vendor/anyhow/tests/ui/wrong-interpolation.rs
new file mode 100644
index 000000000..b870ca713
--- /dev/null
+++ b/vendor/anyhow/tests/ui/wrong-interpolation.rs
@@ -0,0 +1,5 @@
+use anyhow::{bail, Result};
+
+fn main() -> Result<()> {
+ bail!("{} not found");
+}
diff --git a/vendor/anyhow/tests/ui/wrong-interpolation.stderr b/vendor/anyhow/tests/ui/wrong-interpolation.stderr
new file mode 100644
index 000000000..55a296411
--- /dev/null
+++ b/vendor/anyhow/tests/ui/wrong-interpolation.stderr
@@ -0,0 +1,5 @@
+error: 1 positional argument in format string, but no arguments were given
+ --> tests/ui/wrong-interpolation.rs:4:12
+ |
+4 | bail!("{} not found");
+ | ^^