Skip to content

Commit

Permalink
generator: Apply must_use attributes to all struct setter functions
Browse files Browse the repository at this point in the history
All structs are marked as `Copy`, and builders move `self` for a
convenient builder pattern directly on `default()` (using `&mut`
requires first storing the builder on the heap).  This however leads
to builder functions accidentally moving a copy of `self`, mutating it,
and dropping the result directly when the caller did not consume the
returned value in ad-hoc field updates, in turn leaving the author
confused why their code compiles without warnings while the struct was
not updated.

Annotating all builder functions with `#[must_use]` should at least give
them an idea why.
  • Loading branch information
MarijnS95 committed Dec 4, 2023
1 parent befb8cd commit 7d245e5
Show file tree
Hide file tree
Showing 2 changed files with 3,424 additions and 9 deletions.
Loading

0 comments on commit 7d245e5

Please sign in to comment.