mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Merge #6360
6360: Fix unary minus highlighting r=matklad a=Veykril Fixes #6358 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
35ed3d2c00
3 changed files with 14 additions and 1 deletions
|
@ -579,7 +579,14 @@ fn highlight_element(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
T![-] if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
||||||
HighlightTag::NumericLiteral.into()
|
let prefix_expr = element.parent().and_then(ast::PrefixExpr::cast)?;
|
||||||
|
|
||||||
|
let expr = prefix_expr.expr()?;
|
||||||
|
match expr {
|
||||||
|
ast::Expr::Literal(_) => HighlightTag::NumericLiteral,
|
||||||
|
_ => HighlightTag::Operator,
|
||||||
|
}
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
_ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
_ if element.parent().and_then(ast::PrefixExpr::cast).is_some() => {
|
||||||
HighlightTag::Operator.into()
|
HighlightTag::Operator.into()
|
||||||
|
|
|
@ -176,6 +176,9 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
|
|
||||||
<span class="keyword">let</span> <span class="variable declaration callable">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="punctuation">;</span>
|
<span class="keyword">let</span> <span class="variable declaration callable">a</span> <span class="operator">=</span> <span class="punctuation">|</span><span class="value_param declaration">x</span><span class="punctuation">|</span> <span class="value_param">x</span><span class="punctuation">;</span>
|
||||||
<span class="keyword">let</span> <span class="variable declaration callable">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="function">baz</span><span class="punctuation">;</span>
|
<span class="keyword">let</span> <span class="variable declaration callable">bar</span> <span class="operator">=</span> <span class="struct">Foo</span><span class="operator">::</span><span class="function">baz</span><span class="punctuation">;</span>
|
||||||
|
|
||||||
|
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="numeric_literal">-</span><span class="numeric_literal">42</span><span class="punctuation">;</span>
|
||||||
|
<span class="keyword">let</span> <span class="variable declaration">baz</span> <span class="operator">=</span> <span class="operator">-</span><span class="variable">baz</span><span class="punctuation">;</span>
|
||||||
<span class="punctuation">}</span>
|
<span class="punctuation">}</span>
|
||||||
|
|
||||||
<span class="keyword">enum</span> <span class="enum declaration">Option</span><span class="punctuation"><</span><span class="type_param declaration">T</span><span class="punctuation">></span> <span class="punctuation">{</span>
|
<span class="keyword">enum</span> <span class="enum declaration">Option</span><span class="punctuation"><</span><span class="type_param declaration">T</span><span class="punctuation">></span> <span class="punctuation">{</span>
|
||||||
|
|
|
@ -150,6 +150,9 @@ fn main() {
|
||||||
|
|
||||||
let a = |x| x;
|
let a = |x| x;
|
||||||
let bar = Foo::baz;
|
let bar = Foo::baz;
|
||||||
|
|
||||||
|
let baz = -42;
|
||||||
|
let baz = -baz;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Option<T> {
|
enum Option<T> {
|
||||||
|
|
Loading…
Reference in a new issue