proc_macro: Improve Debug representations#49748
Merged
bors merged 2 commits intorust-lang:masterfrom Apr 7, 2018
Merged
Conversation
This commit improves the `fmt::Debug` output of `proc_macro` data structures by primarily focusing on the representation exposed by `proc_macro` rather than the compiler's own internal representation. This cuts down quite a bit on assorted wrapper types and ensure a relatively clean output. Closes rust-lang#49720
Contributor
|
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Member
Author
|
cc @dtolnay |
dtolnay
reviewed
Apr 6, 2018
src/libproc_macro/lib.rs
Outdated
| #[unstable(feature = "proc_macro", issue = "38356")] | ||
| impl fmt::Debug for Span { | ||
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
| write!(f, "{:?} bytes({}...{})", |
Member
There was a problem hiding this comment.
I believe the lo/hi interval is half-open so {}..{} would be more accurate. Like in #49720 the + token is bytes(82..83).
A span covering a single byte, such as for an operator `+` token, should print as e.g. `80..81` rather than `80...81`. The lo end of the range is inclusive and the hi end is exclusive.
Member
|
Here is sample debug output for the tokens TokenStream [
Group {
delimiter: Bracket,
stream: TokenStream [
Term {
sym: a,
span: #0 bytes(80..81)
},
Op {
op: '+',
spacing: Alone,
span: #0 bytes(82..83)
},
Literal {
lit: Integer(
1
),
suffix: None,
span: #0 bytes(84..85)
}
],
span: #0 bytes(79..86)
}
]@bors r+ |
Collaborator
|
📌 Commit 52766b5 has been approved by |
kennytm
added a commit
to kennytm/rust
that referenced
this pull request
Apr 7, 2018
…olnay proc_macro: Improve Debug representations This commit improves the `fmt::Debug` output of `proc_macro` data structures by primarily focusing on the representation exposed by `proc_macro` rather than the compiler's own internal representation. This cuts down quite a bit on assorted wrapper types and ensure a relatively clean output. Closes rust-lang#49720
bors
added a commit
that referenced
this pull request
Apr 7, 2018
Rollup of 9 pull requests Successful merges: - #49510 (Fix anchor position on fields) - #49652 (Fix anchors issue when everything is collapsed) - #49702 (std: Inline some Termination-related methods) - #49728 (add emit_debug_gdb_scripts target option and ..) - #49731 (add THUMB targets to rustup manifest) - #49742 (Using X headings instead of 0.X #49739) - #49748 (proc_macro: Improve Debug representations) - #49750 (bootstrap: Remove the fast path) - #49503 (Inject the `compiler_builtins` crate whenever the `core` crate is injected) Failed merges:
eddyb
reviewed
Apr 13, 2018
| pub struct Literal { | ||
| token: token::Token, | ||
| lit: token::Lit, | ||
| suffix: Option<ast::Name>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit improves the
fmt::Debugoutput ofproc_macrodata structures byprimarily focusing on the representation exposed by
proc_macrorather than thecompiler's own internal representation. This cuts down quite a bit on assorted
wrapper types and ensure a relatively clean output.
Closes #49720