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

Redundancy in trace_macro output #42223

Open
jorendorff opened this issue May 25, 2017 · 1 comment
Open

Redundancy in trace_macro output #42223

jorendorff opened this issue May 25, 2017 · 1 comment
Labels
-Ztrace-macros Unstable option: trace-macros A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jorendorff
Copy link
Contributor

(filed per #42103 (comment) )

trace_macro output now contains both "before" and "after" text.

But often a macro-call expands to another macro-call. In that case, we get redundant lines from trace_macro:

 note: trace_macro
   --> trace-macro.rs:14:5
   |
14 |     println!("Hello, World!");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   |
   = note: expanding `println! { "Hello, World!" }`
   = note: to `print ! ( concat ! ( "Hello, World!" , "\n" ) )`
   = note: expanding `print! { concat ! ( "Hello, World!" , "\n" ) }`
   = note: to `$crate :: io :: _print ( format_args ! ( concat ! ( "Hello, World!" , "\n" ) )
           )`

The second "expanding" note is basically the same as the previous line. We could eliminate that.

Note that it's also common for a macro-call to expand to code that merely contains another macro-call somewhere, and in that case we probably shouldn't elide anything.

@Mark-Simulacrum Mark-Simulacrum added the A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) label Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 27, 2017
@Enselic Enselic added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 14, 2023
@fmease fmease added -Ztrace-macros Unstable option: trace-macros S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Aug 29, 2024
@fmease
Copy link
Member

fmease commented Aug 29, 2024

Since println and panic now lead to only one expansion, here's a new MCVE:

macro_rules! start { () => { end!() }; }
macro_rules! end { () => { () }; }

fn main() { start!(); }

With -Ztrace-macros:

note: trace_macro
 --> hw.rs:4:13
  |
4 | fn main() { start!(); }
  |             ^^^^^^^^
  |
  = note: expanding `start! {  }`
  = note: to `end! ()`
  = note: expanding `end! {  }`
  = note: to `()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Ztrace-macros Unstable option: trace-macros A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-enhancement Category: An issue proposing an enhancement or a PR with one. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants