Skip to content

New trace_macros! messages are inaccurate #42072

@jorendorff

Description

@jorendorff

https://is.gd/8JnZ5V

#![feature(trace_macros)]

fn main() {
    trace_macros!(true);
    assert_eq!(vec![1, 2, 3,].len(), 3);
}

Output is:

rustc 1.19.0-nightly (75b056812 2017-05-15)
note: trace_macro
 --> <anon>:5:5
  |
5 |     assert_eq!(vec![1, 2, 3,].len(), 3);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: expands to `assert_eq! { vec ! [ 1 , 2 , 3 , ] . len (  ) , 3 }`
  = note: expands to `panic! { "assertion failed: `(left == right)` \
                                     (left: `{:?}`, right: `{:?}`)"
          , left_val , right_val }`

note: trace_macro
 --> <anon>:5:16
  |
5 |     assert_eq!(vec![1, 2, 3,].len(), 3);
  |                ^^^^^^^^^^^^^^
  |
  = note: expands to `vec! { 1 , 2 , 3 , }`
  = note: expands to `vec! { 1 , 2 , 3 }`

The first message here is inaccurate. The assert_eq! macro-use does not expand to that panic! macro-use.

trace_macros shows the input to macros, not the output. So instead of "expands to:", it should say "expanding:". But changing the behavior to match what the message says would be even better. ;)

This is a regression because the error messages are new. trace_macros used to just dump token streams to stdout (lol).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions