about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2018-09-02 06:59:02 -0700
committerDavid Tolnay <dtolnay@gmail.com>2018-09-02 14:34:45 -0700
commitc5a561c0abe432006063408dc3371891585319a6 (patch)
tree20d680284235efa0a4598baef109764d493f81f5 /src/libsyntax/parse
parent3480ac2a805f8755f41dba2f081446df9d572986 (diff)
downloadrust-c5a561c0abe432006063408dc3371891585319a6.tar.gz
rust-c5a561c0abe432006063408dc3371891585319a6.zip
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:

    mod m {
        type T =
    }

    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.
Diffstat (limited to 'src/libsyntax/parse')
0 files changed, 0 insertions, 0 deletions