Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix highlighting on single-character Rust consts #3927

Merged
merged 4 commits into from
Sep 21, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion runtime/queries/rust/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@
; -------

((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]+$"))
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
(const_item
name: (identifier) @constant
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary: the above stanza matches constants in all caps. This stanza matches all constant defintions, so it would correctly highlight

const pi: f64 = 3.1415;
//     ^ constant

but it would be confusing because later usages of the constant would only be highlighted as variables

2 * pi * r
//   ^ variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, good catch. I can make a commit later today to address this, if you don't get to it first :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@the-mikedavis Do you think we should remove that stanza entirely, due to the fact that all constants are expected to be declared in all caps by Rust's formatting rules?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I think we're ok to remove this stanza


gavincrawford marked this conversation as resolved.
Show resolved Hide resolved
; ---
; PascalCase identifiers in call_expressions (e.g. `Ok()`)
Expand Down