Uh oh!
There was an error while loading. Please reload this page.
Add proc_macro::Span::{before, after}. - #86165
Conversation
rust-highfive
commented
Jun 9, 2021
(rust-highfive has picked a reviewer for you, use r? to override) |
Uh oh!
There was an error while loading. Please reload this page.
jhpratt
commented
Jun 13, 2021
Part of me would prefer this be called Would it makes sense to repurpose these names and provide a generalized Just a random thought I had from a usability perspective; I could certainly get accustomed to the before/after naming. |
m-ou-se
commented
Jul 28, 2021
@jhpratt Since a span is not a point/location but a range, calling it start and end doesn't feel entirely accurate to me. |
m-ou-se
commented
Sep 8, 2021
r? @dtolnay |
dtolnay
left a comment
There was a problem hiding this comment.
This API looks good to me as implemented.
dtolnay
commented
Sep 9, 2021
@bors r+ |
bors
commented
Sep 9, 2021
📌 Commit f9be6cd has been approved by |
bors
commented
Sep 9, 2021
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
…arth Rollup of 15 pull requests Successful merges: - rust-lang#85200 (Ignore derived Clone and Debug implementations during dead code analysis) - rust-lang#86165 (Add proc_macro::Span::{before, after}.) - rust-lang#87088 (Fix stray notes when the source code is not available) - rust-lang#87441 (Emit suggestion when passing byte literal to format macro) - rust-lang#88546 (Emit proper errors when on missing closure braces) - rust-lang#88578 (fix(rustc): suggest `items` be borrowed in `for i in items[x..]`) - rust-lang#88632 (Fix issues with Markdown summary options) - rust-lang#88639 (rustdoc: Fix ICE with `doc(hidden)` on tuple variant fields) - rust-lang#88667 (Tweak `write_fmt` doc.) - rust-lang#88720 (Rustdoc coverage fields count) - rust-lang#88732 (RustWrapper: avoid deleted unclear attribute methods) - rust-lang#88742 (Fix table in docblocks) - rust-lang#88776 (Workaround blink/chromium grid layout limitation of 1000 rows) - rust-lang#88807 (Fix typo in docs for iterators) - rust-lang#88812 (Fix typo `option` -> `options`.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…tolnay
Add proc_macro::Span::{before, after}.
This adds `proc_macro::Span::before()` and `proc_macro::Span::after()` to get a zero width span at the start or end of the span.
These are equivalent to rustc's `Span::shrink_to_lo()` and `Span::shrink_to_hi()` but with a less cryptic name. They are useful when generating diagnostlics like "missing \<thing\> after \<thing\>".
E.g.
```rust
syn::Error::new(ident.span().after(), "missing `:` after field name").into_compile_error()
```
This adds
proc_macro::Span::before()andproc_macro::Span::after()to get a zero width span at the start or end of the span.These are equivalent to rustc's
Span::shrink_to_lo()andSpan::shrink_to_hi()but with a less cryptic name. They are useful when generating diagnostlics like "missing <thing> after <thing>".E.g.