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

Collapse cross-crate macros in error backtraces #24188

Closed
huonw opened this Issue Apr 8, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@huonw
Copy link
Member

huonw commented Apr 8, 2015

Errors inside macros currently get some serious and intimidating compiler-spew, e.g.

fn main() {
    println!("{}", () + 1);
}

gives

<anon>:2:20: 2:24 error: binary operation `+` cannot be applied to type `()` [E0369]
<anon>:2     println!("{}", () + 1);
                            ^~~~
note: in expansion of format_args!
<std macros>:2:25: 2:58 note: expansion site
<std macros>:1:1: 2:62 note: in expansion of print!
<std macros>:3:1: 3:54 note: expansion site
<std macros>:1:1: 3:58 note: in expansion of println!
<anon>:2:5: 2:28 note: expansion site

Most of the <std macros> lines are useless, as they're talking about implementation details of println! that the user has no control over (the macro is defined in another crate) and almost certainly doesn't care about. It would be much nicer if they were just collapsed to only print the outer call:

<anon>:2:20: 2:24 error: binary operation `+` cannot be applied to type `()` [E0369]
<anon>:2     println!("{}", () + 1);
                            ^~~~
note: in expansion of println!
<anon>:2:5: 2:28 note: expansion site

There's a few edge-cases I can think of:

  • someone working on their own macros and testing/using them in another crate may still be interested in the full backtrace. We could print the full trace if --verbose is passed.
  • macros that call other macros may result in interleaved cross-crate and intra-crate macros, presumably this is addressed by only collapsing contiguous sequences of cross-crate macros
@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Apr 8, 2015

In the case of libstd macros and so forth, it's unclear that we even want the "expansion site".

@brson

This comment has been minimized.

Copy link
Contributor

brson commented Dec 1, 2016

This case looks better today.

@brson brson closed this Dec 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.