Skip to content

Commit

Permalink
tweak wording
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 23, 2023
1 parent df81147 commit 62aff3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/type/type-check/coerce-result-return-value-2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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?),
| +++ ++
Expand All @@ -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?),
| +++ ++
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/type/type-check/coerce-result-return-value.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
| +++ ++
Expand All @@ -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?);
| +++ ++
Expand All @@ -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?)
| +++ ++
Expand All @@ -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?)
| +++ ++
Expand Down

0 comments on commit 62aff3b

Please sign in to comment.