-
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
Add -Z span-debug
to allow for easier debugging of proc macros
#72799
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
I would personally lean towards avoiding the -Z flag and just implementing Debug for the proc_macro::Span type. If people are parsing the output of Debug impls then they're basically asking for trouble, I think it's fine if we end up breaking that in the future. (We can also add an explicit note to the documentation that such parsing is not permitted, and potentially even to the debug output itself). |
@Mark-Simulacrum: In the discussion about
I agree. However, I'd like to avoid even the possibility of breakage until some kind of consensus has been reached about what we do or do not want to expose to proc macros. Even if the majority of crates don't abuse the |
Additionally, I don't think we'd ever want to forward to an internal |
I'd personally keep this as a private patch that I apply only when actually debugging tokens streams (it's a one line change), but |
To elaborate, you never know what you'll need during next debugging. |
My goal is to make the A |
46fbaa0
to
f3f822e
Compare
@petrochenkov: Updated |
Thanks! (This will fail tidy and conflict with #72618 though.) |
This comment has been minimized.
This comment has been minimized.
f3f822e
to
b583f33
Compare
@bors r=petrochenkov |
📌 Commit b583f33a7db66ffce3394e4dce7d663ddce2820c has been approved by |
@Aaron1011 |
@bors r- |
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 rust-lang#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.
b583f33
to
b541d3d
Compare
@petrochenkov: Fixed |
@bors r+ |
📌 Commit b541d3d has been approved by |
…rochenkov 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 rust-lang#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.
…rochenkov 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 rust-lang#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.
Rollup of 10 pull requests Successful merges: - rust-lang#72026 (Update annotate-snippets-rs to 0.8.0) - rust-lang#72583 (impl AsRef<[T]> for vec::IntoIter<T>) - rust-lang#72615 (Fix documentation example for gcov profiling) - rust-lang#72761 (Added the documentation for the 'use' keyword) - rust-lang#72799 (Add `-Z span-debug` to allow for easier debugging of proc macros) - rust-lang#72811 (Liballoc impl) - rust-lang#72963 (Cstring `from_raw` and `into_raw` safety precisions) - rust-lang#73001 (Free `default()` forwarding to `Default::default()`) - rust-lang#73075 (Add comments to `Resolve::get_module`) - rust-lang#73092 (Clean up E0646) Failed merges: r? @ghost
Currently, the
Debug
impl forproc_macro::Span
just prints outthe 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 forproc_macro::Span
simply forwards directly torustc_span::Span
. Once #72618 is merged, this will start displayingactual line numbers.
While
Debug
impls are not subject to Rust's normal stabilityguarnatees, 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.