Skip to content

Commit 00d9268

Browse files
committed
Replace explanation of ordering with one from PR feedback
1 parent 7d11cb8 commit 00d9268

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/coding-guidelines/macros.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,20 @@ Macros
322322
implementations. It's possible to use procedural macros or declarative macros
323323
to do so.
324324

325-
In a declarative macro the ordering of the patterns will be the order that
326-
they are matched against which can lead to unexpected behavior in the case
327-
where we have unique behavior intended for a particular expression. The concern
328-
in particular is that while the ordering may be done correctly when the
329-
macro match rules are written, it's possible in a refactor for them to
325+
The choice of which `transcriber`_
326+
is being used in a declarative macro depends on their declaration order within the macro.
327+
This can lead to unexpected behavior changes in invocations of declarative macros if a new
328+
transciber is inserted before another due to invocations suddenly matching a different transcriber.
329+
330+
The concern in particular is that while the declaration ordering may be done correctly
331+
when the macro match rules are written, it's possible in a refactor for them to
330332
unintentionally be moved around in order.
331333

332334
If needing to specialize logic within the macro based on a particular
333335
expression's value, it is better to not use a declarative macro with multiple rules.
334336

337+
.. _transcriber: https://doc.rust-lang.org/reference/macros-by-example.html
338+
335339
.. non_compliant_example::
336340
:id: non_compl_ex_5vK0CCmePkef
337341
:status: draft

0 commit comments

Comments
 (0)