Bug 1728267 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Some QM_TRY macros contain implicit `ToResult` which makes it easier to use with expressions which don't return `mozilla::Result` directly. However, when we need to add for example `QM_OR_ELSE_WARN`, an explicit `ToResult` must be added. I think it would be better and more consistent if we removed the implicit `ToResult` and used explicit sub macros (like `MOZ_TO_RESULT`) for conversion to `mozilla::Result` instead.

There are other things in favor of the explicit sub macros:
- an explicit conversion to `mozilla::Result` signals a start of an error stack
- `try!` in rust requires a `Result` to be passed as well
- precise error stacks (`QMresult`) need an explicit conversion anyway
- better consistency with existing `MOZ_TO_RESULT_INVOKE` sub macros

So, ideally, if an expression doesn't return `mozilla::Result` we should wrap it with one of these sub macros:
`MOZ_TO_RESULT`
`MOZ_TO_RESULT_INVOKE`
`MOZ_TO_RESULT_INVOKE_TYPED`
`MOZ_TO_RESULT_GET_TYPED`

We will later add QM_ counterparts for functions returning the new `OkOrErr` (`Result<Ok, QMResult`).
Some `QM_TRY` macros contain implicit `ToResult` which makes it easier to use with expressions which don't return `mozilla::Result` directly. However, when we need to add for example `QM_OR_ELSE_WARN`, an explicit `ToResult` must be added. I think it would be better and more consistent if we removed the implicit `ToResult` and used explicit sub macros (like `MOZ_TO_RESULT`) for conversion to `mozilla::Result` instead.

There are other things in favor of the explicit sub macros:
- an explicit conversion to `mozilla::Result` signals a start of an error stack
- `try!` in rust requires a `Result` to be passed as well
- precise error stacks (`QMresult`) need an explicit conversion anyway
- better consistency with existing `MOZ_TO_RESULT_INVOKE` sub macros

So, ideally, if an expression doesn't return `mozilla::Result` we should wrap it with one of these sub macros:
`MOZ_TO_RESULT`
`MOZ_TO_RESULT_INVOKE`
`MOZ_TO_RESULT_INVOKE_TYPED`
`MOZ_TO_RESULT_GET_TYPED`

We will later add QM_ counterparts for functions returning the new `OkOrErr` (`Result<Ok, QMResult`).

Back to Bug 1728267 Comment 0