mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 15:58:47 +00:00
Fix highlighting for field init shorthand
This commit is contained in:
parent
d057afb945
commit
77af7b087f
2 changed files with 4 additions and 5 deletions
|
@ -41,7 +41,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
||||||
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
|
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable.mut">vec</span> = <span class="text">Vec</span>::<span class="text">new</span>();
|
||||||
<span class="keyword.control">if</span> <span class="keyword">true</span> {
|
<span class="keyword.control">if</span> <span class="keyword">true</span> {
|
||||||
<span class="keyword">let</span> <span class="variable">x</span> = <span class="literal.numeric">92</span>;
|
<span class="keyword">let</span> <span class="variable">x</span> = <span class="literal.numeric">92</span>;
|
||||||
<span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="text">x</span>, <span class="field">y</span>: <span class="literal.numeric">1</span> });
|
<span class="variable.mut">vec</span>.<span class="text">push</span>(<span class="type">Foo</span> { <span class="field">x</span>, <span class="field">y</span>: <span class="literal.numeric">1</span> });
|
||||||
}
|
}
|
||||||
<span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal.numeric">0</span>); }
|
<span class="keyword.unsafe">unsafe</span> { <span class="variable.mut">vec</span>.<span class="text">set_len</span>(<span class="literal.numeric">0</span>); }
|
||||||
|
|
||||||
|
|
|
@ -102,11 +102,10 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
|
||||||
COMMENT => tags::LITERAL_COMMENT,
|
COMMENT => tags::LITERAL_COMMENT,
|
||||||
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => tags::LITERAL_STRING,
|
STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => tags::LITERAL_STRING,
|
||||||
ATTR => tags::LITERAL_ATTRIBUTE,
|
ATTR => tags::LITERAL_ATTRIBUTE,
|
||||||
|
// Special-case field init shorthand
|
||||||
|
NAME_REF if node.parent().and_then(ast::RecordField::cast).is_some() => tags::FIELD,
|
||||||
|
NAME_REF if node.ancestors().any(|it| it.kind() == ATTR) => continue,
|
||||||
NAME_REF => {
|
NAME_REF => {
|
||||||
if node.ancestors().any(|it| it.kind() == ATTR) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap();
|
let name_ref = node.as_node().cloned().and_then(ast::NameRef::cast).unwrap();
|
||||||
let name_kind =
|
let name_kind =
|
||||||
classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind);
|
classify_name_ref(db, InFile::new(file_id.into(), &name_ref)).map(|d| d.kind);
|
||||||
|
|
Loading…
Reference in a new issue