-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Debuggable macro expansions #2117
Conversation
Thanks a lot for the RFC, @hsivonen! I think this is a good idea as proposed. Regarding the open questions:
cc @vadimcn and @rust-lang/compiler (and maybe @rust-lang/lang and @rust-lang/dev-tools should take a quick look at this too). |
For context, these issues are a problem for some of our production customers. It'd be good to get feedback from the compiler team soon. |
I think the behavior of fn f() { // 17
{ // 18
one(); // 18
{ // 18
two(); // 18
} // 18
{ // 18
three(); // 19 <--- retain line number if the statement comes from macro invocation
four(); // 20 <---
} // 18
} // 18
} // 22 |
Related, for error messages, we apply a same-crate heuristic, where if the macro is in the same crate, we give details from inside the macro, and if not we treat it as opaque. If we add an attribute like |
I think this proposal looks reasonable. Thanks for writing it up! Re unsolved questions: if code blocks passed as macro argument are not affected by #[collapse_debuginfo], it might break "step-over" functionality in debuggers, so this scenario needs to be tested if you decide to go this route. |
@michaelwoerister do you want to move toward FCP at this point, to land this ahead of the impl period? |
We discussed this in dev-tools meeting today. We approve of the RFC in principal, but would like to experiment with an implementation. Given the impl period, we'll not do anything with this RFC for now, but consider us approving a hypothetical 'experimental RFC' so that we can experiment with an unstable implementation. We'll revisit this RFC once we have some experience with the implementation. |
results for macros that are not assert-like and not print-like but that expand | ||
to substantial code. The current approach of collapsing debug information by | ||
default makes non-assert-like, non-print-like macro usage result in code that | ||
is on debuggable, that doesn't get useful panic/crash stacks in CI or in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "on debuggable" should be changed "not debuggable" here, and "at that" should be changed to "and that" on the subsequent line.
@michaelwoerister @tromey @hsivonen @vadimcn is anyone interested in doing an initial implementation of this? I think that is the next step here. |
Would it make sense to have an attribute that could annotate the call-site of the macro to select collapsed vs expanded debug info which overrides the setting made at the macro declaration site? |
For the use cases I've encountered so far, the choice has been something that'd belong better on the macro declaration than on the macro invocation. I don't know if others have use cases where being able to override the choice from the macro invocation site would make sense, but I'm pretty confident that at least the primary choice belongs in the macro declaration. |
Hi, any update here? It has been a year and a half since last update. |
Discussed at T-lang backlog bonanza. Points of feedback:
We recommend you file a compiler-team MCP, if you think you yourself have time to do the associated work associated with implementing the change or chartering a project group to do the prototyping described above. If the implementation effort requires the addition of small attributes or other small changes, those can be discussed by the T-lang design team concurrently with the ongoing implementation effort. |
Based on the above, I'm going to go ahead and close this RFC -- as @pnkfelix noted, I think the best next step is to work towards the implementation side. |
Filed an MCP. |
Improves debuggability of, panic stacks for and profiling attribution of code expanded from non-assert-like macros.
By default, annotate code expanded from a macro with debug location info corresponding to the macro definition (i.e. the behavior that's currently available on nightly via
-Zdebug-macros
). Add an annotation#[collapse_debuginfo]
to enable a particular macro definition to opt to have the expansion annotated with debug location info corresponding to the macro invocation (i.e. the current default behavior).Rust issue, PR that created the current behavior, Internals forum post
Rendered