Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `proc_macro::Span` inspection APIs #54725
Comments
alexcrichton
added
A-macros
T-lang
T-libs
B-unstable
C-tracking-issue
labels
Oct 1, 2018
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Oct 1, 2018
alexcrichton
referenced this issue
Oct 1, 2018
Closed
Tracking issue for RFC 1566: Procedural macros #38356
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Oct 1, 2018
xd009642
referenced this issue
Oct 2, 2018
Open
tracking issue for necessity of cargo +nightly tarpaulin #150
This comment has been minimized.
This comment has been minimized.
softprops
commented
Oct 10, 2018
|
I wanted to shed some pain this is causing with tarpaulin. Tarpaulin has worked amazingly well for me and my company as a replacement for kcov which historically been a pain to get accurate, reliable and correct results. At the moment tarpaulin stands as the most promising goto option for codecoverage in rust and just feels more like the only first class tooling option. Having one of those when choosing to invest in a technology is important for many company's adoption story for checking off code quantity checkmarks. When they see that rust doesn't have a reasonable code quality story that works on stable rust, that's can result in a "pass" rather than "I'll take it". There are currently some work arounds for making this work-ish on stable but it feels very much like the story serde was in a year or so ago when you wanted to show all your friends how amazing serde was but then was embarrassed to show what it took to make work on stable because of a macro stabilization blocker. |
alexcrichton
referenced this issue
Oct 20, 2018
Open
Feature request: get access to the exact text source (&str) behind a Span #110
This comment has been minimized.
This comment has been minimized.
JakeTherston
commented
Oct 28, 2018
|
With procedural macros having reached a point where they're very useful on stable, I expect many users will find themselves needing access to this information. Would it be reasonable to only stabilize parts of the |
kevinmehall
added a commit
to kevinmehall/rust-peg
that referenced
this issue
Nov 3, 2018
mystor
referenced this issue
Nov 12, 2018
Open
proc_macro support for reading files/strings to spanned TokenStream #55904
nikomatsakis
referenced this issue
Jan 11, 2019
Merged
Introduce proc_macro::Span::source_text #55780
This comment has been minimized.
This comment has been minimized.
|
I have a concern about exposing My understanding is that, if one adds a blank line to the start of the file, the line_column information of the input spans to proc macro changes. That means that IDE would have to re-expand procedural macros even after insignificant white space changes. I would feel more confident if proc-macros were strictly a pure function from the input token stream to output token stream. This can be achieved, for example, by making line-column infocation relative to the start of macro invocation (as opposed to relative to the start of the file). I don't feel that exposing absolute position is necessary the end of the world: IDE can track if a macro actually makes use of the info, or it can supply macro with some fake line/columns. But it's hard to tell if such hacks would work well in practice, and it's hard to experiment with them for the lack of IDE which handled proc-macros incrementally.... |
This comment has been minimized.
This comment has been minimized.
davidlattimore
commented
Feb 2, 2019
|
If the parser allocated IDs to every AST node, then, and this is the hard part, when an edit was made to the source, the parser tried to keep those IDs the same in all the non-edited code and only allocate new IDs for new nodes, that would allow spans to be kept completely separate from the AST. Those IDs could be passed through macro expansion without causing unnecessary invalidations. If something needed a span later on, it could then go back and ask the parser for the span for that particular AST node ID. I feel like having an incremental parser is important, not because parsing is the bottleneck, but because it underpins everything else. |
This comment has been minimized.
This comment has been minimized.
|
@davidlattimore this is fascinating, but slightly off-topic for the issue. I've created a thread on internals: https://internals.rust-lang.org/t/macros-vs-incremental-parsing/9323 |
alexcrichton commentedOct 1, 2018
This issue is intended to track a number of unstable APIs which are used to inspect the contents of a
Spanfor information like the file name, byte position, manufacturing new spans, combining them, etc.This issue tracks the
proc_macro_spanunstable feature.I'm not currently sure what the blockers are for stabilization, but I know there are some! If others would like to fill this in that'd be great!