summaryrefslogtreecommitdiff
path: root/rust-rustfmt.el
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>2022-11-01 13:22:58 -0700
committerJim Blandy <jimb@red-bean.com>2022-11-02 09:35:45 -0700
commit42ba58df6c3071576f2ddc6e0a285db57b7e690b (patch)
tree36f5ac3cd3d929a7a4c6a27ae131d5ff52a5579b /rust-rustfmt.el
parentb4537b6f5fa65626c1bab944681b35769cab9b5c (diff)
downloadrust-mode-42ba58df6c3071576f2ddc6e0a285db57b7e690b.tar.gz
Simplify and correct angle bracket propertizing and macro argument detection.
Fixes #465. When `rust-syntax-propertize` uses `rust-macro-scopes` to find ranges of text that are macro arguments, it ends up inadvertently poisoning the `syntax-ppss` cache by applying it to text that doesn't have the necessary `syntax-table` properties applied yet - the very job that `rust-syntax-propertize` is trying to do. However, `rust-macro-scopes` does much more work than necessary. Rather than producing a list of ranges of macro arguments, we can just use the list of enclosing opening parens provided by syntax-ppss, checking each paren to see if it seems to be a macro or `macro_rules` call. We have to keep syntax-ppss's cache accurate for other reasons anyway, so we might as well just use its data, rather than introducing another cache of our own - especially a problematic one (see #465). * rust-mode.el (rust-in-macro): Consult `syntax-ppss`'s list of enclosing parens, rather than using `rust-macro-scope`. Remove optional arguments, which were only used by tests. (rust-macro-scopes, rust-macro-scope): Delete. Now we just use `syntax-ppss`'s internal cache. (rust-syntax-propertize): Don't bind `rust-macro-scopes`. (rust-looking-back-macro-rules): New function. (rust-looking-back-macro): Support a space between macro name and `!`, by consulting `rust-expression-introducers`. (rust-expression-introducers): New constant. Use in `rust-looking-back-macro` and `rust-is-in-expression-context`. (rust-is-in-expression-context): Use `rust-expression-introducers`. (rust-looking-back-ident): Don't use `looking-back`. We've already moved to the correct spot for `looking-at`, within a `save-excursion`. * rust-mode-tests.el: Update tests.
Diffstat (limited to 'rust-rustfmt.el')
0 files changed, 0 insertions, 0 deletions