-
Notifications
You must be signed in to change notification settings - Fork 593
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
[Rust] Add + use<>
syntax
#4139
base: master
Are you sure you want to change the base?
Conversation
- match: '<' | ||
scope: punctuation.definition.generic.begin.rust | ||
set: | ||
- match: '>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to add a meta scope to generics.
- match: '>' | |
- match: '>' | |
- meta_scope: meta.generic.rust |
- match: \b(Self)\b | ||
scope: keyword.other.rust | ||
- match: '{{identifier}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self
is already defined as storage type in no-path-type-names
context and identifiers should also receive valuable scope names. Types are currently unscoped as other identifiers are.
I'd therefore suggest to include ordinary identifiers
context, which would also - even if maybe not required - handle fully qualified identifiers.
- match: \b(Self)\b | |
scope: keyword.other.rust | |
- match: '{{identifier}}' | |
- include: identifiers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's not be 100% accurate either, I'd rather include types
here since that is meant to be used in situations where types are expected. It matches lifetimes as well as stray identifiers and commonly known stdlib types. Alternatively, you could refactor the types context a bit and only include the relevant things for UseBoundGenericArg
here, which are lifetimes and (pathed) identifiers (with a type scope).
Commas still need to be matched separately, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, reading the spec properly, pathed identifiers aren't supported and it is also unlikely for built-in names to be used since this is supposed to refer to generics and a generic with a built-in name would shadow it.
In that case, please instead simply include all-generic-type-names
.
This adds support for the
+ use<>
precise capture syntax to Rust which was introduced in Rust 1.82.Documentation