Bug 1625855 - Replace MOZ_MUST_USE with [[nodiscard]] in some Servo Rust code. r=emilio

Are there any Rust crates outside mozilla-central that include or emit Mozilla C++ code that should be updated to use [[nodiscard]] instead of MOZ_MUST_USE?

Depends on D68751

Differential Revision: https://phabricator.services.mozilla.com/D69319
This commit is contained in:
Chris Peterson
2020-04-02 08:27:59 +00:00
parent ffd96c3edd
commit 5bc9d3f177
2 changed files with 4 additions and 4 deletions

View File

@@ -496,7 +496,7 @@ explicitly mark the return value should always be checked. For example:
create();
// for C++, add this in *declaration*, do not add it again in implementation.
MOZ_MUST_USE nsresult
[[nodiscard]] nsresult
DoSomething();
There are some exceptions:
@@ -511,7 +511,7 @@ There are some exceptions:
SomeMap::GetValue(const nsString& key, nsString& value);
If most callers need to check the output value first, then adding
``MOZ_MUST_USE`` might be too verbose. In this case, change the return value
``[[nodiscard]]`` might be too verbose. In this case, change the return value
to void might be a reasonable choice.
There is also a static analysis attribute ``MOZ_MUST_USE_TYPE``, which can

View File

@@ -450,7 +450,7 @@ renaming_overrides_prefixing = true
"""
# TODO(emilio): Add hooks to cbindgen to be able to generate MOZ_MUST_USE_TYPE
# or MOZ_MUST_USE on the functions.
# or [[nodiscard]] on the functions.
"Owned" = """
UniquePtr<GeckoType> Consume() {
UniquePtr<GeckoType> ret(ptr);
@@ -546,7 +546,7 @@ renaming_overrides_prefixing = true
// Increase the reference count.
inline void IncrementRef();
// Release the reference count, and return whether the result must be freed or not.
MOZ_MUST_USE inline bool DecrementRef();
[[nodiscard]] inline bool DecrementRef();
"""
"ArcSlice" = """