Skip to content

Wrong coloring at function-like procedural macro #8209

@chamoretto

Description

@chamoretto

Environment

  • IntelliJ Rust plugin version: 0.4.162.4280-213-nightly
  • Rust toolchain version: 1.57.0-nightly (8f8092cc3 2021-09-28) x86_64-pc-windows-msvc
  • IDE name and version: CLion 2021.3 (CL-213.5744.254)
  • Operating system: Windows 10 10.0
  • Macro expansion engine: new
  • Name resolution engine: new
  • Additional experimental features: org.rust.cargo.features.settings.gutter, org.rust.cargo.evaluate.build.scripts, org.rust.macros.proc

All experimantal features enabled.

image

Problem description

Depends on inner parsing algorithms of your proc-macros, you can face some coloring problems.

  • Case 1, 2: macro was colored almost correctly, but only for first 2 arguments, the Go To Definition feature also works only for first arguments (i.e. it witll work for User and executor, but won't work with login_var).
  • Case 3 has broken color near const.
  • Cases 4, 5 and 6 demonstrates differently broken painting. Go To Definition won't work at all, even with first argument User, which works at cases 1 and 2.

image

It turns out that expanding macros and painting code inside a macro brackets depends on the internal parsing rules? What should be the parsing to make the text in the macro look correct for the end user? (assuming the macro expands to valid code, i.e. at cases 1 and 2 which expands to valid code, but colored correctly only for first 2 arguments)

Steps to reproduce

  1. Clone repo, i've created special branch for this issue - https://github.com/chamoretto/function-like-macro-expansion-problem/tree/issue-coloring-examples
  2. Try to expand examples from test function

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions