about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-01-23 14:46:30 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-01-23 14:47:00 +0000
commit62aff3bbc75468bedf751b01a746e52886be760c (patch)
treee7fce50872f29f4aae006b9e67b430e93db8426b
parentdf81147b51f95441c8db74eda92b5c5fadecb20e (diff)
downloadrust-62aff3bbc75468bedf751b01a746e52886be760c.tar.gz
rust-62aff3bbc75468bedf751b01a746e52886be760c.zip
tweak wording
-rw-r--r--compiler/rustc_hir_typeck/src/demand.rs3
-rw-r--r--tests/ui/type/type-check/coerce-result-return-value-2.stderr4
-rw-r--r--tests/ui/type/type-check/coerce-result-return-value.stderr8
3 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index 97490194e25..3f185dfae02 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -735,7 +735,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             .must_apply_modulo_regions()
         {
             err.multipart_suggestion(
-                "you can rely on the implicit conversion that `?` does to transform the error type",
+                "use `?` to coerce and return an appropriate `Err`, and wrap the resulting value \
+                 in `Ok` so the expression remains of type `Result`",
                 vec![
                     (expr.span.shrink_to_lo(), "Ok(".to_string()),
                     (expr.span.shrink_to_hi(), "?)".to_string()),
diff --git a/tests/ui/type/type-check/coerce-result-return-value-2.stderr b/tests/ui/type/type-check/coerce-result-return-value-2.stderr
index 64a8c779fce..5992162341e 100644
--- a/tests/ui/type/type-check/coerce-result-return-value-2.stderr
+++ b/tests/ui/type/type-check/coerce-result-return-value-2.stderr
@@ -9,7 +9,7 @@ LL |         true => x,
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |         true => Ok(x?),
    |                 +++ ++
@@ -25,7 +25,7 @@ LL |         true => return x,
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |         true => return Ok(x?),
    |                        +++ ++
diff --git a/tests/ui/type/type-check/coerce-result-return-value.stderr b/tests/ui/type/type-check/coerce-result-return-value.stderr
index 18993b3cef1..55015352078 100644
--- a/tests/ui/type/type-check/coerce-result-return-value.stderr
+++ b/tests/ui/type/type-check/coerce-result-return-value.stderr
@@ -8,7 +8,7 @@ LL |     x
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |     Ok(x?)
    |     +++ ++
@@ -23,7 +23,7 @@ LL |     return x;
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |     return Ok(x?);
    |            +++ ++
@@ -39,7 +39,7 @@ LL |         x
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |         Ok(x?)
    |         +++ ++
@@ -55,7 +55,7 @@ LL |         x
    |
    = note: expected enum `Result<_, B>`
               found enum `Result<_, A>`
-help: you can rely on the implicit conversion that `?` does to transform the error type
+help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
    |
 LL |         Ok(x?)
    |         +++ ++