Repository navigation
Clarify the call-site hierarchy and add a non-trivial example - #3069
Closed
isHeSatoshi wants to merge 1 commit into
Closed
isHeSatoshi wants to merge 1 commit into
isHeSatoshi wants to merge 1 commit into
Conversation
The section explained the call-site hierarchy only with an example in which every invocation is written in the source, so the hierarchy came out as a single `ROOT -> baz` chain with no intermediate expansion. It was hard to tell what the hierarchy tracks, and why a plain identifier such as `baz` has one at all. Say what the hierarchy records: where code was written, rather than how it was produced, with the invocation's syntax context as the `call_site` link. Note that it is a property of every token, not just of macro invocations, which is why a token like `baz` is named in the notation. Then add the case that actually produces a non-trivial chain: an invocation written inside another macro's definition. When the invocation is merely passed in as an argument it is written at the call site, which is why the first example is trivial.
This comment was marked as low quality.
This comment was marked as low quality.
Collaborator
|
Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1874.
The call-site hierarchy was described only with an example where every invocation is written in the source:
That gives
ROOT -> baz, with no intermediate expansion, which makes the hierarchy hard to read: it is not obvious what is being tracked, and it is not obvious why a plain identifier likebazhas a hierarchy at all when the section is about macro invocations.This change:
SyntaxContextas thecall_sitelink;bazin the notation just identifies whose hierarchy is being described;bar!(baz)is written as the argument tofoo!, so it is not produced byfoo!, andbazkeeps the call site's context;I checked the second example against the compiler rather than reasoning about it. With
-Zunpretty=expanded,hygieneon nightly,barreportscall_site_ctxt: #4where#4is the context created byfoo's expansion (the first example reportscall_site_ctxt: #0for both invocations), and thebazin the output carries that same#4context. Extending the chain to three macros givescall_site_ctxt#0,#4,#5fora,bandc, withbazat#6, i.e. one fresh context per nesting level.No new links are added; the section reuses the existing
[callsite]and[sc]definitions.