Make a shorter version for constructing error values of Result<V,E>

RESOLVED FIXED in Firefox 55

Status

()

RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: nbp, Assigned: nbp)

Tracking

unspecified
mozilla55
Points:
---

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

2 years ago
To construct an error value today, we have to use either the constructor of the Result<V,E>, or to use the GenericErrorResult<E>.

In IonBuilder (Bug 1286505) we have multiple Ok types, but a single generic error type, in which case making such error is made verbose by the function

  mozilla::MakeGenericErrorResult

I suggest to rename this function to

  mozilla::Err

In order to follow the same naming as Rust code, and in the continuity of the Ok() constructor.
(Assignee)

Comment 1

2 years ago
Created attachment 8820717 [details] [diff] [review]
Rename mozilla::MakeGenericErrorResult to mozilla::Err.
Attachment #8820717 - Flags: review?(jwalden+bmo)
(Assignee)

Updated

2 years ago
Assignee: nobody → nicolas.b.pierron
Status: NEW → ASSIGNED

Comment 2

2 years ago
Comment on attachment 8820717 [details] [diff] [review]
Rename mozilla::MakeGenericErrorResult to mozilla::Err.

Review of attachment 8820717 [details] [diff] [review]:
-----------------------------------------------------------------

::: js/src/jit/Ion.h
@@ +40,5 @@
>  
>  template <typename V>
>  using AbortReasonOr = mozilla::Result<V, AbortReason>;
>  using mozilla::Ok;
> +using mozilla::Err;

This should go before Ok for alphabetical purposes.

::: mfbt/tests/TestResult.cpp
@@ +6,5 @@
>  
>  #include "mozilla/Result.h"
>  
>  using mozilla::GenericErrorResult;
> +using mozilla::Err;

E before G, so move this one line earlier.
Attachment #8820717 - Flags: review?(jwalden+bmo) → review+

Comment 3

2 years ago
Pushed by npierron@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/3ec4fd0c06c9
Rename mozilla::MakeGenericErrorResult to mozilla::Err. r=Waldo

Comment 4

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/3ec4fd0c06c9
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.