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

Make it easy to use external-macro-backtrace #6049

Closed
dhardy opened this issue Sep 18, 2018 · 4 comments
Closed

Make it easy to use external-macro-backtrace #6049

dhardy opened this issue Sep 18, 2018 · 4 comments
Labels
A-rustflags Area: rustflags S-propose-close Status: A team member has nominated this for closing, pending further input from the team

Comments

@dhardy
Copy link

dhardy commented Sep 18, 2018

Yes, stupid title, for a stupid issue. I know it was decided a while back not to support pass-through of unknown options to Rustc, which implies that Rustc options should be replicated in Cargo.

Currently, one must switch to the nightly compiler then can:

  1. RUSTFLAGS="-Z external-macro-backtrace" cargo test
    This works (in Bash), but requires all dependencies to be recompiled (unnecessarily since the option is only required for the failing crate, generally the final one).
  2. Run cargo test -v, copy the failing command and append -Z external-macro-backtrace
    This works but is tedious.

There are two ways to solve this:

  1. Enable the switch by default, everywhere (in nightly compilers). This would of course have to be a Rust decision not a Cargo one. See: show macro backtrace with -Z flag rust#45545
  2. Add a Cargo switch to add the appropriate Rustc switch (possibly only to the last binary).
@najamelan
Copy link

najamelan commented Apr 22, 2019

This might have to be a different issue, but I would like to add:
Print line numbers that correspond to the file where the macro is defined. Currently the line numbers don't match to anything I can make sense of, and I have to rely on recognizing the code in the expanded errors to find the actual error location.

ps: oh yeah, this is cargo repo, so it must be an issue on rust I suppose. Do others agree I should open such issue or do the line numbers make sense for you?

@eddyb
Copy link
Member

eddyb commented Jan 16, 2020

Currently the line numbers don't match to anything I can make sense of, and I have to rely on recognizing the code in the expanded errors to find the actual error location.

This is due to how we serialize macros across crates, rust-lang/rust#66364 should take care of that.

@epage
Copy link
Contributor

epage commented Oct 24, 2023

#5546 is about discoverability of rustc -Z flags which was resolved in #12857.

Whats not clear to me is the benefit of duplicating -Z flags vs having people set them. I'm going to propose to the cargo team that we close this.

This works (in Bash), but requires all dependencies to be recompiled (unnecessarily since the option is only required for the failing crate, generally the final one).

This is the nature of RUSTFLAGS and improvements are being tracked in #8716 and #12739.

@epage epage added the S-propose-close Status: A team member has nominated this for closing, pending further input from the team label Oct 24, 2023
@weihanglo
Copy link
Member

Generally, we don't easily duplicate -Z flag from rustc to cargo. Cargo would need to think at a higher level than rustc for the usability as a "build tool".

For now, if you want to apply rustflags only to the final binary, [cargo rustc] is the command to-go.

Second that we can close this as #12857 provides sufficient information to fix the human error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustflags Area: rustflags S-propose-close Status: A team member has nominated this for closing, pending further input from the team
Projects
None yet
Development

No branches or pull requests

6 participants