summary refs log tree commit diff
path: root/src/libsyntax/parse/lexer/tokentrees.rs
AgeCommit message (Collapse)AuthorLines
2018-09-09Don't compute padding of braces unless they are unmatchedEsteban Küber-23/+20
2018-09-09Auto merge of #53902 - dtolnay:group, r=petrochenkovbors-3/+3
proc_macro::Group::span_open and span_close Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation: ```rust mod m { type T = } ``` ```console error: expected type, found `}` --> src/main.rs:3:1 | 3 | } | ^ ``` On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above. This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476. ```diff impl Group { fn span(&self) -> Span; + fn span_open(&self) -> Span; + fn span_close(&self) -> Span; } ``` Fixes #48187 r? @alexcrichton
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-3/+3
2018-09-05Change wording of unclosed delimiter labelEsteban Küber-1/+4
2018-09-05Provide more context for unenclosed delimitersEsteban Küber-2/+38
* When encountering EOF, point at the last opening brace that does not have the same indentation level as its close delimiter. * When encountering the wrong type of close delimiter, point at the likely correct open delimiter to give a better idea of what went wrong.
2018-09-05Reword un-closed delimiter labelEsteban Küber-2/+2
2018-08-17Rollup merge of #53373 - estebank:unclosed, r=petrochenkovkennytm-11/+19
Tweak unclosed delimiter parser error
2018-08-15Do not emit "incorrect close delimiter" twice in the same placeEsteban Küber-11/+17
2018-08-15Tweak unclosed delimiter parser errorEsteban Küber-2/+4
2018-08-13A few cleanups and minor improvements for the lexerljedrz-0/+5
2018-06-09Crate-ify and delete unused code in syntax::parseMark Simulacrum-1/+1
2018-05-18rustc: Fix joint-ness of stringified token-streamsAlex Crichton-11/+12
This commit fixes `StringReader`'s parsing of tokens which have been stringified through procedural macros. Whether or not a token tree is joint is defined by span information, but when working with procedural macros these spans are often dummy and/or overridden which means that they end up considering all operators joint if they can! The fix here is to track the raw source span as opposed to the overridden span. With this information we can more accurately classify `Punct` structs as either joint or not. Closes #50700
2017-08-30Make fields of `Span` privateVadim Petrochenkov-4/+3
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-1/+1
Like #43008 (f668999), but _much more aggressive_.
2017-06-26Implement `quote!` and other `proc_macro` API.Jeffrey Seyfried-4/+8
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-13/+11
2017-01-23Remove `open_span` and `close_span` from `Delimited`.Jeffrey Seyfried-5/+1
2017-01-17Introduce `string_reader.parse_all_token_trees()`.Jeffrey Seyfried-0/+138