-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation. #67359
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Meta: some mix between functional and formatting changes here, perhaps it will look better if rebased on master where everything is rustfmt-ed. |
ping from triage, @eddyb can you rebase and apply reviewers' comment, thanks! |
On this topic:
I think this flag is used by folks? It seems like at minimum we should announce the change in a PSA on Inside Rust. A deprecation period would be polite, but it's probably not required. I guess we don't really document |
bcf92e8
to
4722c83
Compare
This comment has been minimized.
This comment has been minimized.
4722c83
to
8261365
Compare
This comment has been minimized.
This comment has been minimized.
8261365
to
000e1bf
Compare
Blocked on #68407. |
rustc_span: return an impl Iterator instead of a Vec from macro_backtrace. Having `Span::macro_backtrace` produce an `impl Iterator<Item = ExpnData>` allows #67359 to use it instead of rolling its own similar functionality. The move from `MacroBacktrace` to `ExpnData` (which the first two commits are prerequisites for) both eliminates unnecessary allocations, and is strictly more flexible (exposes more information). r? @petrochenkov
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a1676c7
to
96af578
Compare
@bors r=petrochenkov |
📌 Commit 96af578 has been approved by |
… r=petrochenkov Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation. This is my attempt at dealing with rust-lang#66364 (comment), although I'm not sure it's the least disruptive one. The behavior of `-Zexternal-macro-backtrace` was already to enable full macro backtraces for *all* macros, the only part of it that was specific to cross-crate macros was showing this when *not used*: ``` note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) ``` After this PR: * the flag is renamed to `-Zmacro-backtrace` * do we need to have a deprecation period? cc @rust-lang/compiler * the message informing you about the flag is always shown when an expansion of a bang macro/attribute/derive is involved, not just cross-crate ones * this accounts for most of the changes in tests * we could perhaps only show it for the bang macro case? feels odd for derives * `fix_multispans_in_std_macros` is split into `fix_multispans_in_extern_macros` and `render_multispans_macro_backtrace` * this roughly reverts the non-behavioral parts of rust-lang#46605, which combined the two functionalities * not sure where the old `std_macros` name came from, perhaps the `<std macros>` synthetic "file"? even then, odd that `std` specifically was mentioned * `render_multispan_macro_backtrace`, by default (i.e. without `-Zmacro-backtrace`), hides the `in this macro invocation` label specifically to avoid redundancy in the diagnostic * that is, showing the macro use site is only useful when the diagnostic is inside the macro definition and the user can't otherwise tell which use site it applies to, not when the diagnostic is at/inside the use site already (which would make the label redundant) * before, it was only checking for the situation in which a cross-crate macro *definition* span would be replaced with the invocation span, which both made the connection to redundancy unobvious, and didn't help with other redundancy (e.g. when the diagnostic was pointing to an argument inside the macro invocation) * this accounts for the remaining test changes, which I've first noticed in rust-lang#66364 (comment) but only later understood as part of this PR (hence the "redundancy" descriptions) This PR is not needed for rust-lang#66364, but it would help, as after this PR there's only one `.span_to_filename(...).is_macros()` check (i.e. for `<... macros>` synthetic "files") left in `rustc_errors`, and it's much more self-contained. r? @petrochenkov
Rollup of 6 pull requests Successful merges: - #67359 (Rename -Zexternal-macro-backtrace to -Zmacro-backtrace and clean up implementation.) - #68524 (Generator Resume Arguments) - #68791 (implement proper linkchecker hardening) - #68886 (Mark fn map_or() as eagerly evaluated.) - #68888 (error code examples: replace some more ignore with compile_fail) - #68894 (Update E0565 examples) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #68907) made this pull request unmergeable. Please resolve the merge conflicts. |
Rustup rust-lang/rust#67359 cc rust-lang/rust#67359 changelog: none
Rustup rust-lang/rust#67359 cc rust-lang/rust#67359 changelog: none
This is my attempt at dealing with #66364 (comment), although I'm not sure it's the least disruptive one.
The behavior of
-Zexternal-macro-backtrace
was already to enable full macro backtraces for all macros, the only part of it that was specific to cross-crate macros was showing this when not used:After this PR:
-Zmacro-backtrace
fix_multispans_in_std_macros
is split intofix_multispans_in_extern_macros
andrender_multispans_macro_backtrace
std_macros
name came from, perhaps the<std macros>
synthetic "file"? even then, odd thatstd
specifically was mentionedrender_multispan_macro_backtrace
, by default (i.e. without-Zmacro-backtrace
), hides thein this macro invocation
label specifically to avoid redundancy in the diagnosticrmeta::MacroDef
#66364 (comment) but only later understood as part of this PR (hence the "redundancy" descriptions)This PR is not needed for #66364, but it would help, as after this PR there's only one
.span_to_filename(...).is_macros()
check (i.e. for<... macros>
synthetic "files") left inrustc_errors
, and it's much more self-contained.r? @petrochenkov