]> git.lizzy.rs Git - rust.git/commitdiff
tweak wording
authorEsteban Küber <esteban@kuber.com.ar>
Mon, 23 Jan 2023 14:46:30 +0000 (14:46 +0000)
committerEsteban Küber <esteban@kuber.com.ar>
Mon, 23 Jan 2023 14:47:00 +0000 (14:47 +0000)
compiler/rustc_hir_typeck/src/demand.rs
tests/ui/type/type-check/coerce-result-return-value-2.stderr
tests/ui/type/type-check/coerce-result-return-value.stderr

index 97490194e2558cc8763a7c76473112a42ce685f3..3f185dfae0241a88535146273a986b124b350467 100644 (file)
@@ -735,7 +735,8 @@ pub(crate) fn note_result_coercion(
             .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()),
index 64a8c779fce76df3d9266dfb7dd77133bb2ae471..5992162341e6e25198d6361572f47847a70f5a9c 100644 (file)
@@ -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?),
    |                        +++ ++
index 18993b3cef1b997e53d32223399f5996be616670..550153520782c683848d4bdd0d7b2ad13d9089ec 100644 (file)
@@ -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?)
    |         +++ ++