Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify eager macro explanation #1872

Open
wants to merge 2,258 commits into
base: master
Choose a base branch
from

Conversation

Arthur-Milchior
Copy link
Contributor

This CL tries to improve the text around the order in which macro are expanded in various related way.

  1. Remove duplication of "smoother".

Its first occurrence is

a smoother user experience. As an example

It seems that we'll have an example of a smooth user experience. It is not the case, we have an example of macro expansion. Removing this occurrence of "smooth" help understand this won't be considered in the following example.

As the same "smooth" explanation is given below, nothing is lost.

  1. Use an actual example of where eager expansion is needed

This example comes, modified, from
https://doc.rust-lang.org/std/macro.compile_error.html . It uses cfg to cause a compile error if something is not as expected.

As far as my understanding of rust goes, this could not be done with call-by-name evaluation.

At the same time, this example shows the steps of
rewritting. (Approximatively. I still use code represented as strings instead of a list of token/an AST, for the sake of the readability)

  1. Not all macros are in the queue

According to the way step 1 of the algorithm is currently written, it seems that, in foo!(bar!(baz));, both foo!(bar!(baz)) and bar!(baz) should be in the queue. This is false, as bar! should not be evaluated until foo! is.

So the rewritting state that the traversal does not enter unevaluated macros. It also add a note about the exception of non-eager macros.

Technically, it should state that, for non-eager macro, the macro itself should not be evaluated until all of its argument containing macros are evaluated. But I guess it's already fit in the case "macro expansion is not resolved".

tshepang and others added 30 commits February 21, 2023 22:56
ehuss and others added 23 commits December 14, 2023 20:28
Enabling the profiler runtime is an essential part of being able to properly
work on the coverage instrumentation code.

There's already a mention of it on this page, but it's made in passing and is
easy to miss. This patch adds a much more prominent section containing
recommended `config.toml` settings, including `profiler = true`.
The current link provides a link to two versions of the book, both redirecting to the "current version", which is the link this PR uses
…#1849)

* add some explain for rustbot commands

* add more details about shortcuts

* fix words on `r=someone`

Co-authored-by: Yuki Okushi <[email protected]>

---------

Co-authored-by: Yuki Okushi <[email protected]>
This CL tries to improve the text around the order in which macro are expanded
in various related way.

1. Remove duplication of "smoother".

Its first occurrence is
> a smoother user experience.  As an example

It seems that we'll have an example of a smooth user experience. It is not the
case, we have an example of macro expansion. Removing this occurrence of
"smooth" help understand this won't be considered in the following example.

As the same "smooth" explanation is given below, nothing is lost.

2. Use an actual example of where eager expansion is needed

This example comes, modified, from
https://doc.rust-lang.org/std/macro.compile_error.html . It uses cfg to cause a
compile error if something is not as expected.

As far as my understanding of rust goes, this could not be done with
call-by-name evaluation.

At the same time, this example shows the steps of
rewritting. (Approximatively. I still use  code represented as strings instead
of a list of token/an AST, for the sake of the readability)

3. Not all macros are in the queue

According to the way step 1 of the algorithm is currently written, it seems
that, in `foo!(bar!(baz));`, both `foo!(bar!(baz))` and `bar!(baz)` should be in
the queue. This is false, as `bar!` should not be evaluated until `foo!` is.

So the rewritting state that the traversal does not enter unevaluated macros. It
also add a note about the exception of non-eager macros.

Technically, it should state that, for non-eager macro, the macro itself should
not be evaluated until all of its argument containing macros are evaluated.
But I guess it's already fit in the case "macro expansion is not resolved".
@jieyouxu jieyouxu added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Oct 8, 2024
@jieyouxu jieyouxu added A-macros Area: macros (general sense) T-compiler Relevant to compiler team A-macro-expansion Area: macro expansion labels Nov 4, 2024
@Kobzol
Copy link
Contributor

Kobzol commented Jan 5, 2025

Sorry, due to me messing up a git operation, we sadly had to force-push the whole commit history of rustc-dev-guide :( If you'd like to update this pull request, you will have to rebase it in a special way onto the new commit history (the new master):

git fetch origin --all
git checkout <pr-branch>
git rebase --onto origin/master origin/master-old
git push --force-with-lease

More context can be found here.

@Arthur-Milchior
Copy link
Contributor Author

@Kobzol to be frank, it's been opened for a year, without reivew. So, unless anyone tell me they expect to be reviewed and merged (with or without correction first), I don't intend to spend more time on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro-expansion Area: macro expansion A-macros Area: macros (general sense) S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content T-compiler Relevant to compiler team
Projects
None yet
Development

Successfully merging this pull request may close these issues.