-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Stabilize proc_macro::Span::{start,end,line,column}. #139865
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
Stabilize proc_macro::Span::{start,end,line,column}. #139865
Conversation
bf6b54b
to
c5c9362
Compare
@rfcbot merge |
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
This is the most exciting thing I've seen for the state of proc macros in years hahaha |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Does |
Has there been a discussion about whether to change the return values of I believe that using |
Same as everywhere else in Rust, such as in I'll document it. |
The I don't think there will be a lot of confusion: the line+column numbers are exactly what rustc would show for a diagnostic, and the line number matches you see in your editor. In text editors, code listings, compiler diagnostics, etc., line numbers always start at one. Just documenting it seems more than enough. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
FCP completed above r? tgross35 |
…location, r=tgross35 Stabilize proc_macro::Span::{start,end,line,column}. This stabilizes part of rust-lang#54725 Specifically, the part related to getting the location of a span: ```rust impl Span { pub fn start(&self) -> Span; // Empty span at the start of this span pub fn end(&self) -> Span; // Empty span at the end of this span pub fn line(&self) -> usize; // Line where the span starts pub fn column(&self) -> usize; // Column where the span starts } ``` History of this part of the API: Originally, `start` and `end` returned a `LineColumn` struct (containing the line and column). This has been simplified/changed: - No more `LineColumn`: `Span` now directly has `.line()` and `.column()` methods. This means we can easily add `.byte_offset()` or `.byte_range()` in the future if we want to. - `Span::start()` and `Span::end()` are now the equivalent of rustc's internal `shrink_to_lo()` and `shrink_to_hi()`. This means you can do e.g. `span.end().column()`, removing the need for a `span.end_column()` or similar.
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#139865 (Stabilize proc_macro::Span::{start,end,line,column}.) - rust-lang#140086 (If creating a temporary directory fails with permission denied then retry with backoff) - rust-lang#140216 (Document that "extern blocks must be unsafe" in Rust 2024) - rust-lang#140220 (Fix detection of main function if there are expressions around it) - rust-lang#140253 (Add XtensaAsmPrinter) - rust-lang#140272 (Improve error message for `||` (or) in let chains) - rust-lang#140305 (Track per-obligation recursion depth only if there is inference in the new solver) - rust-lang#140306 (handle specialization in the new trait solver) - rust-lang#140308 (stall generator witness obligations: add regression test) r? `@ghost` `@rustbot` modify labels: rollup
…location, r=tgross35 Stabilize proc_macro::Span::{start,end,line,column}. This stabilizes part of rust-lang#54725 Specifically, the part related to getting the location of a span: ```rust impl Span { pub fn start(&self) -> Span; // Empty span at the start of this span pub fn end(&self) -> Span; // Empty span at the end of this span pub fn line(&self) -> usize; // Line where the span starts pub fn column(&self) -> usize; // Column where the span starts } ``` History of this part of the API: Originally, `start` and `end` returned a `LineColumn` struct (containing the line and column). This has been simplified/changed: - No more `LineColumn`: `Span` now directly has `.line()` and `.column()` methods. This means we can easily add `.byte_offset()` or `.byte_range()` in the future if we want to. - `Span::start()` and `Span::end()` are now the equivalent of rustc's internal `shrink_to_lo()` and `shrink_to_hi()`. This means you can do e.g. `span.end().column()`, removing the need for a `span.end_column()` or similar.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#139865 (Stabilize proc_macro::Span::{start,end,line,column}.) - rust-lang#140086 (If creating a temporary directory fails with permission denied then retry with backoff) - rust-lang#140216 (Document that "extern blocks must be unsafe" in Rust 2024) - rust-lang#140253 (Add XtensaAsmPrinter) - rust-lang#140272 (Improve error message for `||` (or) in let chains) - rust-lang#140305 (Track per-obligation recursion depth only if there is inference in the new solver) - rust-lang#140306 (handle specialization in the new trait solver) - rust-lang#140308 (stall generator witness obligations: add regression test) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#139865 - m-ou-se:stabilize-proc-macro-span-location, r=tgross35 Stabilize proc_macro::Span::{start,end,line,column}. This stabilizes part of rust-lang#54725 Specifically, the part related to getting the location of a span: ```rust impl Span { pub fn start(&self) -> Span; // Empty span at the start of this span pub fn end(&self) -> Span; // Empty span at the end of this span pub fn line(&self) -> usize; // Line where the span starts pub fn column(&self) -> usize; // Column where the span starts } ``` History of this part of the API: Originally, `start` and `end` returned a `LineColumn` struct (containing the line and column). This has been simplified/changed: - No more `LineColumn`: `Span` now directly has `.line()` and `.column()` methods. This means we can easily add `.byte_offset()` or `.byte_range()` in the future if we want to. - `Span::start()` and `Span::end()` are now the equivalent of rustc's internal `shrink_to_lo()` and `shrink_to_hi()`. This means you can do e.g. `span.end().column()`, removing the need for a `span.end_column()` or similar.
This stabilizes part of #54725
Specifically, the part related to getting the location of a span:
History of this part of the API:
Originally,
start
andend
returned aLineColumn
struct (containing the line and column).This has been simplified/changed:
LineColumn
:Span
now directly has.line()
and.column()
methods. This means we can easily add.byte_offset()
or.byte_range()
in the future if we want to.Span::start()
andSpan::end()
are now the equivalent of rustc's internalshrink_to_lo()
andshrink_to_hi()
. This means you can do e.g.span.end().column()
, removing the need for aspan.end_column()
or similar.