From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/try-trait/try-operator-on-main.stderr | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/ui/try-trait/try-operator-on-main.stderr (limited to 'tests/ui/try-trait/try-operator-on-main.stderr') diff --git a/tests/ui/try-trait/try-operator-on-main.stderr b/tests/ui/try-trait/try-operator-on-main.stderr new file mode 100644 index 000000000..7cd38e0cf --- /dev/null +++ b/tests/ui/try-trait/try-operator-on-main.stderr @@ -0,0 +1,53 @@ +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/try-operator-on-main.rs:7:31 + | +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +LL | // error for a `Try` type on a non-`Try` fn +LL | std::fs::File::open("foo")?; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual>` is not implemented for `()` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/try-operator-on-main.rs:10:5 + | +LL | ()?; + | ^^^ the `?` operator cannot be applied to type `()` + | + = help: the trait `Try` is not implemented for `()` + +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> $DIR/try-operator-on-main.rs:10:7 + | +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +... +LL | ()?; + | ^ cannot use the `?` operator in a function that returns `()` + | + = help: the trait `FromResidual<_>` is not implemented for `()` + +error[E0277]: the trait bound `(): Try` is not satisfied + --> $DIR/try-operator-on-main.rs:14:25 + | +LL | try_trait_generic::<()>(); + | ^^ the trait `Try` is not implemented for `()` + | +note: required by a bound in `try_trait_generic` + --> $DIR/try-operator-on-main.rs:17:25 + | +LL | fn try_trait_generic() -> T { + | ^^^ required by this bound in `try_trait_generic` + +error[E0277]: the `?` operator can only be applied to values that implement `Try` + --> $DIR/try-operator-on-main.rs:19:5 + | +LL | ()?; + | ^^^ the `?` operator cannot be applied to type `()` + | + = help: the trait `Try` is not implemented for `()` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. -- cgit v1.2.3