mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Assign mutable semantic token modifier to assignment operators
This commit is contained in:
parent
b3337c26db
commit
d1256a3709
3 changed files with 10 additions and 7 deletions
|
@ -55,7 +55,6 @@ pub(super) fn element(
|
||||||
name_ref,
|
name_ref,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple token-based highlighting
|
// Simple token-based highlighting
|
||||||
COMMENT => {
|
COMMENT => {
|
||||||
let comment = element.into_token().and_then(ast::Comment::cast)?;
|
let comment = element.into_token().and_then(ast::Comment::cast)?;
|
||||||
|
@ -132,16 +131,18 @@ pub(super) fn element(
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
_ if parent_matches::<ast::PrefixExpr>(&element) => HlOperator::Other.into(),
|
_ if parent_matches::<ast::PrefixExpr>(&element) => HlOperator::Other.into(),
|
||||||
T![+] | T![-] | T![*] | T![/] | T![+=] | T![-=] | T![*=] | T![/=]
|
T![+] | T![-] | T![*] | T![/] if parent_matches::<ast::BinExpr>(&element) => {
|
||||||
if parent_matches::<ast::BinExpr>(&element) =>
|
|
||||||
{
|
|
||||||
HlOperator::Arithmetic.into()
|
HlOperator::Arithmetic.into()
|
||||||
}
|
}
|
||||||
T![|] | T![&] | T![!] | T![^] | T![|=] | T![&=] | T![^=]
|
T![+=] | T![-=] | T![*=] | T![/=] if parent_matches::<ast::BinExpr>(&element) => {
|
||||||
if parent_matches::<ast::BinExpr>(&element) =>
|
Highlight::from(HlOperator::Arithmetic) | HlMod::Mutable
|
||||||
{
|
}
|
||||||
|
T![|] | T![&] | T![!] | T![^] if parent_matches::<ast::BinExpr>(&element) => {
|
||||||
HlOperator::Bitwise.into()
|
HlOperator::Bitwise.into()
|
||||||
}
|
}
|
||||||
|
T![|=] | T![&=] | T![^=] if parent_matches::<ast::BinExpr>(&element) => {
|
||||||
|
Highlight::from(HlOperator::Bitwise) | HlMod::Mutable
|
||||||
|
}
|
||||||
T![&&] | T![||] if parent_matches::<ast::BinExpr>(&element) => {
|
T![&&] | T![||] if parent_matches::<ast::BinExpr>(&element) => {
|
||||||
HlOperator::Logical.into()
|
HlOperator::Logical.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,6 +195,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="macro">noop!</span><span class="parenthesis">(</span><span class="macro">noop</span><span class="macro">!</span><span class="parenthesis">(</span><span class="numeric_literal">1</span><span class="parenthesis">)</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
<span class="macro">noop!</span><span class="parenthesis">(</span><span class="macro">noop</span><span class="macro">!</span><span class="parenthesis">(</span><span class="numeric_literal">1</span><span class="parenthesis">)</span><span class="parenthesis">)</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> <span class="operator">=</span> <span class="numeric_literal">42</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">x</span> <span class="operator">=</span> <span class="numeric_literal">42</span><span class="semicolon">;</span>
|
||||||
|
<span class="variable mutable">x</span> <span class="arithmetic mutable">+=</span> <span class="numeric_literal">1</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration mutable">y</span> <span class="operator">=</span> <span class="operator">&</span><span class="keyword">mut</span> <span class="variable mutable">x</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration mutable">y</span> <span class="operator">=</span> <span class="operator">&</span><span class="keyword">mut</span> <span class="variable mutable">x</span><span class="semicolon">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="operator">&</span><span class="variable mutable">y</span><span class="semicolon">;</span>
|
<span class="keyword">let</span> <span class="variable declaration">z</span> <span class="operator">=</span> <span class="operator">&</span><span class="variable mutable">y</span><span class="semicolon">;</span>
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,7 @@ fn main() {
|
||||||
noop!(noop!(1));
|
noop!(noop!(1));
|
||||||
|
|
||||||
let mut x = 42;
|
let mut x = 42;
|
||||||
|
x += 1;
|
||||||
let y = &mut x;
|
let y = &mut x;
|
||||||
let z = &y;
|
let z = &y;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue