Skip to content

Conversation

@copybara-service
Copy link

Mark mutable repeated fields/maps as [[nodiscard]]

Since these fields have implicit presence, these are no-ops if the returned
pointer is unused. These are logically constant, but named "mutable_..." and
are non-const methods of the class in order to return the non-const references.
Ignoring the return value likely indicates an omission on the part of the
caller, an error by confusing it with explicit presence fields (like scalar
submessages or strings), or a call that can be cleaned up.

Since these fields have implicit presence, these are no-ops if the returned
pointer is unused.  These are logically constant, but named "mutable_..." and
are non-const methods of the class in order to return the non-const references.
Ignoring the return value likely indicates an omission on the part of the
caller, an error by confusing it with explicit presence fields (like scalar
submessages or strings), or a call that can be cleaned up.

PiperOrigin-RevId: 832394000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant