about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2021-02-21 15:26:48 +0900
committerGitHub <noreply@github.com>2021-02-21 15:26:48 +0900
commit2793859e86ee37f32ccf01b05fc1869753b85c6a (patch)
tree53e6f53c4117e464b3f26ed0bd357f43a45203ab
parentb9040c717c1730b6246c197bc438f6be97739228 (diff)
parent8ae05dfdf6014e8538ef11f989bc493363cc87ab (diff)
downloadrust-2793859e86ee37f32ccf01b05fc1869753b85c6a.tar.gz
rust-2793859e86ee37f32ccf01b05fc1869753b85c6a.zip
Rollup merge of #82233 - ijackson:try-block-type-test, r=Mark-Simulacrum
try-back-block-type test: Use TryFromSliceError for From test

Using `i32` is rather fragile because it has many implementations.  Recently in an early draft of another MR (#82228) I did something that introduced a new `i32 as From<something>` impl and this test broke.

TryFromSliceError is nice because it doesn't seem likely to grow new conversions.  We still have one conversion, from Infallible.

My other MR is going to be reworked and won't need this any more but having done it I thought I would submit it rather than just throw it away.  Sorry for the tiny MR.
-rw-r--r--src/test/ui/try-block/try-block-bad-type.rs2
-rw-r--r--src/test/ui/try-block/try-block-bad-type.stderr10
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<u32, i32> = try {
+    let res: Result<u32, std::array::TryFromSliceError> = 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:
-             <i32 as From<NonZeroI32>>
-             <i32 as From<bool>>
-             <i32 as From<i16>>
-             <i32 as From<i8>>
-           and 2 others
+             <TryFromSliceError as From<Infallible>>
    = note: required by `from`
 
 error[E0271]: type mismatch resolving `<Result<i32, i32> as Try>::Ok == &str`