diff options
| author | Ralf Jung <post@ralfj.de> | 2020-06-08 09:55:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-08 09:55:26 +0200 |
| commit | e13508786808800b4bc13d49bd5fd1245bc41171 (patch) | |
| tree | 3d13a18ef335b86689aa2ef2ec0b4f0148e8497b /src/librustc_session | |
| parent | 89d8979c9a6044fcdb0269d5b7cb8600db9bca5c (diff) | |
| parent | b541d3da5d9f89407c7072f4a6d65872cf30a577 (diff) | |
Rollup merge of #72799 - Aaron1011:feature/span-debug, r=petrochenkov
Add `-Z span-debug` to allow for easier debugging of proc macros Currently, the `Debug` impl for `proc_macro::Span` just prints out the byte range. This can make debugging proc macros (either as a crate author or as a compiler developer) very frustrating, since neither the actual filename nor the `SyntaxContext` is displayed. This commit adds a perma-unstable flag `-Z span-debug`. When enabled, the `Debug` impl for `proc_macro::Span` simply forwards directly to `rustc_span::Span`. Once #72618 is merged, this will start displaying actual line numbers. While `Debug` impls are not subject to Rust's normal stability guarnatees, we probably shouldn't expose any additional information on stable until `#![feature(proc_macro_span)]` is stabilized. Otherwise, we would be providing a 'backdoor' way to access information that's supposed be behind unstable APIs.
Diffstat (limited to 'src/librustc_session')
| -rw-r--r-- | src/librustc_session/options.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index a38e7f063d7..d22c6ec9d7d 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -996,6 +996,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "make the current crate share its generic instantiations"), show_span: Option<String> = (None, parse_opt_string, [TRACKED], "show spans for compiler debugging (expr|pat|ty)"), + span_debug: bool = (false, parse_bool, [UNTRACKED], + "forward proc_macro::Span's `Debug` impl to `Span`"), // o/w tests have closure@path span_free_formats: bool = (false, parse_bool, [UNTRACKED], "exclude spans when debug-printing compiler state (default: no)"), |
