diff options
| author | surechen <chenshuo17@huawei.com> | 2024-06-09 17:20:25 +0800 |
|---|---|---|
| committer | surechen <chenshuo17@huawei.com> | 2024-06-12 11:33:22 +0800 |
| commit | 0b3fec9388d358b0b48d1ea2f83ff43468402f23 (patch) | |
| tree | 195b44bd84a9d2bafdb328bb3cf1541df87e6249 /tests/ui/try-trait | |
| parent | f3ff2f16c8f59fe5db9ec3382e4d2cc913e376a3 (diff) | |
| download | rust-0b3fec9388d358b0b48d1ea2f83ff43468402f23.tar.gz rust-0b3fec9388d358b0b48d1ea2f83ff43468402f23.zip | |
For E0277 suggest adding `Result` return type for function which using QuesionMark `?` in the body.
Diffstat (limited to 'tests/ui/try-trait')
| -rw-r--r-- | tests/ui/try-trait/try-operator-on-main.stderr | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/ui/try-trait/try-operator-on-main.stderr b/tests/ui/try-trait/try-operator-on-main.stderr index 7cd38e0cf95..ba6eacde68f 100644 --- a/tests/ui/try-trait/try-operator-on-main.stderr +++ b/tests/ui/try-trait/try-operator-on-main.stderr @@ -8,6 +8,16 @@ LL | std::fs::File::open("foo")?; | ^ cannot use the `?` operator in a function that returns `()` | = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` +help: consider adding return type + | +LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> { +LL | // error for a `Try` type on a non-`Try` fn + ... +LL | try_trait_generic::<()>(); +LL + +LL + Ok(()) +LL + } + | error[E0277]: the `?` operator can only be applied to values that implement `Try` --> $DIR/try-operator-on-main.rs:10:5 |
