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

trace_macros output should use span_note? #22597

Closed
kmcallister opened this issue Feb 20, 2015 · 2 comments
Closed

trace_macros output should use span_note? #22597

kmcallister opened this issue Feb 20, 2015 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@kmcallister
Copy link
Contributor

No description provided.

@kmcallister kmcallister added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Feb 20, 2015
@huonw huonw added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 20, 2015
@asolove
Copy link

asolove commented Apr 25, 2015

I am interested in improving the trace_macros output, but there is a strongly-worded note that trace_macros "is a nasty hack that will certainly be removed." If it's going to be around for a while, though, I might take a crack at this.

The program:

#![feature(trace_macros)]

macro_rules! double {
    ($x:expr) => (2 * $x)
}

fn main() {
    trace_macros!(true);
    println!("{}", double!(21));
}

currently outputs:

println! { "{}" , double ! ( 21 ) }
print! { concat ! ( "{}" , "\n" ) , double ! ( 21 ) }
double! { 21 }
42

What is the desired output? I suspect it includes showing the span of the currently-expanding macro and then showing the expansion back in the original source location?

@brson
Copy link
Contributor

brson commented Jun 27, 2016

Triage: still could be improved, not clear how. Probably not E-easy.

@brson brson removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jun 27, 2016
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 9, 2017
Use diagnostics for trace_macro instead of println

When using `trace_macro`, use `span_label`s instead of `println`:

```rust
note: trace_macro
  --> $DIR/trace-macro.rs:14:5
   |
14 |     println!("Hello, World!");
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expands to `println! { "Hello, World!" }`
   = note: expands to `print! { concat ! ( "Hello, World!" , "\n" ) }`
```

Fix rust-lang#22597.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

No branches or pull requests

4 participants