about summary refs log tree commit diff
path: root/src/test/ui/try-trait
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2021-07-17 11:13:50 -0700
committerEsteban Küber <esteban@kuber.com.ar>2021-07-19 08:43:35 -0700
commitba052bd8de1459acb6809215b0bedf4ea476ef9a (patch)
treef6ed28030012d73e09f041b7f94d78fced448771 /src/test/ui/try-trait
parentc78ebb7bdcfc924a20fd069891ffe1364d6814e7 (diff)
downloadrust-ba052bd8de1459acb6809215b0bedf4ea476ef9a.tar.gz
rust-ba052bd8de1459acb6809215b0bedf4ea476ef9a.zip
Various diagnostics clean ups/tweaks
* Always point at macros, including derive macros
* Point at non-local items that introduce a trait requirement
* On private associated item, point at definition
Diffstat (limited to 'src/test/ui/try-trait')
-rw-r--r--src/test/ui/try-trait/bad-interconversion.stderr48
-rw-r--r--src/test/ui/try-trait/option-to-result.stderr12
-rw-r--r--src/test/ui/try-trait/try-on-option-diagnostics.stderr24
-rw-r--r--src/test/ui/try-trait/try-on-option.stderr12
-rw-r--r--src/test/ui/try-trait/try-operator-on-main.stderr24
5 files changed, 100 insertions, 20 deletions
diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr
index f5b315c2519..5cecf9128bb 100644
--- a/src/test/ui/try-trait/bad-interconversion.stderr
+++ b/src/test/ui/try-trait/bad-interconversion.stderr
@@ -11,7 +11,11 @@ LL |     Ok(Err(123_i32)?)
              <u8 as From<NonZeroU8>>
              <u8 as From<bool>>
    = note: required because of the requirements on the impl of `FromResidual<Result<Infallible, i32>>` for `Result<u64, u8>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result`
   --> $DIR/bad-interconversion.rs:11:12
@@ -25,7 +29,11 @@ LL | | }
    | |_- this function returns a `Result`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
   --> $DIR/bad-interconversion.rs:17:31
@@ -38,7 +46,11 @@ LL | | }
    | |_- this function returns a `Result`
    |
    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
   --> $DIR/bad-interconversion.rs:22:22
@@ -51,7 +63,11 @@ LL | | }
    | |_- this function returns an `Option`
    |
    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
   --> $DIR/bad-interconversion.rs:27:33
@@ -64,7 +80,11 @@ LL | | }
    | |_- this function returns an `Option`
    |
    = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
   --> $DIR/bad-interconversion.rs:32:39
@@ -77,7 +97,11 @@ LL | | }
    | |_- this function returns a `ControlFlow`
    |
    = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `ControlFlow<String>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
   --> $DIR/bad-interconversion.rs:37:12
@@ -91,7 +115,11 @@ LL | | }
    | |_- this function returns a `ControlFlow`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `ControlFlow<u64>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator in a function that returns `ControlFlow<B, _>` can only be used on other `ControlFlow<B, _>`s (with the same Break type)
   --> $DIR/bad-interconversion.rs:43:29
@@ -106,7 +134,11 @@ LL | | }
    |
    = help: the trait `FromResidual<ControlFlow<u8, Infallible>>` is not implemented for `ControlFlow<i64>`
    = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 8 previous errors
 
diff --git a/src/test/ui/try-trait/option-to-result.stderr b/src/test/ui/try-trait/option-to-result.stderr
index 9f7d80d4f23..f89813e729f 100644
--- a/src/test/ui/try-trait/option-to-result.stderr
+++ b/src/test/ui/try-trait/option-to-result.stderr
@@ -10,7 +10,11 @@ LL | | }
    | |_- this function returns a `Result`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
   --> $DIR/option-to-result.rs:11:6
@@ -24,7 +28,11 @@ LL | | }
    | |_- this function returns an `Option`
    |
    = help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/try-trait/try-on-option-diagnostics.stderr b/src/test/ui/try-trait/try-on-option-diagnostics.stderr
index e7c67c21bb3..bb65aae561f 100644
--- a/src/test/ui/try-trait/try-on-option-diagnostics.stderr
+++ b/src/test/ui/try-trait/try-on-option-diagnostics.stderr
@@ -10,7 +10,11 @@ LL | | }
    | |_- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
   --> $DIR/try-on-option-diagnostics.rs:14:10
@@ -25,7 +29,11 @@ LL | |     };
    | |_____- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
   --> $DIR/try-on-option-diagnostics.rs:26:14
@@ -38,7 +46,11 @@ LL | |         }
    | |_________- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`)
   --> $DIR/try-on-option-diagnostics.rs:39:14
@@ -51,7 +63,11 @@ LL | |         }
    | |_________- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/try-trait/try-on-option.stderr b/src/test/ui/try-trait/try-on-option.stderr
index 604baa8550b..b522dd5709b 100644
--- a/src/test/ui/try-trait/try-on-option.stderr
+++ b/src/test/ui/try-trait/try-on-option.stderr
@@ -10,7 +10,11 @@ LL | | }
    | |_- this function returns a `Result`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
   --> $DIR/try-on-option.rs:13:6
@@ -24,7 +28,11 @@ LL | | }
    | |_- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/try-trait/try-operator-on-main.stderr b/src/test/ui/try-trait/try-operator-on-main.stderr
index 7d42c2e4d10..dd893cadff7 100644
--- a/src/test/ui/try-trait/try-operator-on-main.stderr
+++ b/src/test/ui/try-trait/try-operator-on-main.stderr
@@ -12,7 +12,11 @@ LL | | }
    | |_- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the `?` operator can only be applied to values that implement `Try`
   --> $DIR/try-operator-on-main.rs:10:5
@@ -21,7 +25,11 @@ LL |     ()?;
    |     ^^^ the `?` operator cannot be applied to type `()`
    |
    = help: the trait `Try` is not implemented for `()`
-   = note: required by `branch`
+note: required by `branch`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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
@@ -39,7 +47,11 @@ LL | | }
    | |_- this function should return `Result` or `Option` to accept `?`
    |
    = help: the trait `FromResidual<_>` is not implemented for `()`
-   = note: required by `from_residual`
+note: required by `from_residual`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn from_residual(residual: R) -> Self;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the trait bound `(): Try` is not satisfied
   --> $DIR/try-operator-on-main.rs:14:25
@@ -57,7 +69,11 @@ LL |     ()?;
    |     ^^^ the `?` operator cannot be applied to type `()`
    |
    = help: the trait `Try` is not implemented for `()`
-   = note: required by `branch`
+note: required by `branch`
+  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
+   |
+LL |     fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 5 previous errors