From 8ae05dfdf6014e8538ef11f989bc493363cc87ab Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 17 Feb 2021 19:13:51 +0000 Subject: [PATCH] try-back-block-type test: Use TryFromSliceError for From test Using `i32` is rather fragile because it has many implementations - and indeed I'm about to add one. TryFromSliceError is nice because it doesn't seem likely to grow new conversions. We still have one conversion, from Infallible. Signed-off-by: Ian Jackson --- src/test/ui/try-block/try-block-bad-type.rs | 2 +- src/test/ui/try-block/try-block-bad-type.stderr | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/test/ui/try-block/try-block-bad-type.rs b/src/test/ui/try-block/try-block-bad-type.rs index 496ba145810..ef6e690e1bd 100644 --- a/src/test/ui/try-block/try-block-bad-type.rs +++ b/src/test/ui/try-block/try-block-bad-type.rs @@ -3,7 +3,7 @@ #![feature(try_blocks)] pub fn main() { - let res: Result = try { + let res: Result = try { Err("")?; //~ ERROR `?` couldn't convert the error 5 }; diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index 2d1313d7d0e..75a42c0d6b7 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -1,16 +1,12 @@ -error[E0277]: `?` couldn't convert the error to `i32` +error[E0277]: `?` couldn't convert the error to `TryFromSliceError` --> $DIR/try-block-bad-type.rs:7:16 | LL | Err("")?; - | ^ the trait `From<&str>` is not implemented for `i32` + | ^ the trait `From<&str>` is not implemented for `TryFromSliceError` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following implementations were found: - > - > - > - > - and 2 others + > = note: required by `from` error[E0271]: type mismatch resolving ` as Try>::Ok == &str` -- 2.44.0