Commit 26c86a6
authored
Rollup merge of rust-lang#67359 - eddyb:macro-backtrace-all-the-same, 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? @petrochenkovFile tree
291 files changed
+1082
-277
lines changed- src
- bootstrap
- librustc_errors
- librustc_session
- librustc_span
- test
- rustdoc-ui
- ui-fulldeps
- internal-lints
- ui
- allocator
- borrowck
- codemap_tests
- conditional-compilation
- const-generics
- array-impls
- consts
- const-eval
- control-flow
- min_const_fn
- cross
- cross-crate-macro-backtrace
- cross-file-errors
- custom_test_frameworks
- deprecation
- derives
- did_you_mean
- dollar-crate
- editions
- error-codes
- feature-gates
- half-open-range-patterns
- hr-subtype
- hygiene
- if
- imports
- in-band-lifetimes
- include-macros
- infinite
- internal
- issues
- lifetimes
- lint
- liveness
- macro_backtrace
- macros
- malformed
- match
- methods
- mismatched_types
- missing
- never_type
- on-unimplemented
- parser
- macro
- pattern
- privacy
- proc-macro
- range
- reachable
- regions
- rfc-1937-termination-trait
- rfc-2361-dbg-macro
- rust-2018
- uniform-paths
- span
- suggestions
- try-block
- tuple/tuple-struct-fields
- type
- ascription
- type-check
- union
- unused
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
291 files changed
+1082
-277
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
847 | 847 | | |
848 | 848 | | |
849 | 849 | | |
850 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
851 | 857 | | |
852 | 858 | | |
853 | 859 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | | - | |
| 177 | + | |
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| |||
0 commit comments