-
Couldn't load subscription status.
- Fork 1.9k
Semantic type for logical not #20891
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
Semantic type for logical not #20891
Conversation
| (T![!], MACRO_RULES) => HlPunct::MacroBang.into(), | ||
| (T![!], NEVER_TYPE) => HlTag::BuiltinType.into(), | ||
| (T![!], PREFIX_EXPR) => HlOperator::Logical.into(), | ||
| (T![!], PREFIX_EXPR) => HlOperator::Negation.into(), |
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.
| (T![!], PREFIX_EXPR) => HlOperator::Negation.into(), | |
| (T![!], PREFIX_EXPR) => HlOperator::Negation.into() | HlOperator::Logical.into(), |
We should include both.
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.
Thanks for your review. It looks however (I did not find the online cargo-doc-generation of Rust-analyzer to provide a link) that Highlight only provides BitOr for HlMod, not for other Highlights
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 also hesitated to know whether Negation was actually disjoint from Logical (since they are now two separate variants of the HlOperator enum).
I think we could find reasons for both. My reason for "it is OK to dissociate them" is the fact that ! is unary while &&and || are binary, so they may be seen as quite a different class of operators.
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.
Nothing in the name "logical" implies a binary operator. And in fact, the boolean negation operator is a logical operator by common definition.
However you're right that there is currently no way to combine operator tags, and implementing that won't be trivial (although it's possible), therefore I'll accept this PR.
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.
Thanks!
|
changelog fix (first contribution) add |
…ical_not Semantic type for logical not
Resolve #19943
This makes the following code highliting possible. How lovely.

See the issue for more info on how to have it actually used by VSCode's extension (basically, this requires "rust-analyzer.semanticHighlighting.operator.specialization.enable": true in VSCode's user config)