mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Color for
as a regular keyword when it's part of impl _ for _
This commit is contained in:
parent
3f1c73633e
commit
63b75a40c8
3 changed files with 28 additions and 1 deletions
|
@ -33,6 +33,16 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
|
|||
<span class="keyword">pub</span> <span class="field declaration">y</span>: <span class="builtin_type">i32</span>,
|
||||
}
|
||||
|
||||
<span class="keyword">trait</span> <span class="trait declaration">Bar</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="keyword">self</span>) -> <span class="builtin_type">i32</span>;
|
||||
}
|
||||
|
||||
<span class="keyword">impl</span> <span class="trait">Bar</span> <span class="keyword">for</span> <span class="struct">Foo</span> {
|
||||
<span class="keyword">fn</span> <span class="function declaration">bar</span>(&<span class="keyword">self</span>) -> <span class="builtin_type">i32</span> {
|
||||
<span class="keyword">self</span>.<span class="field">x</span>
|
||||
}
|
||||
}
|
||||
|
||||
<span class="keyword">static</span> <span class="keyword">mut</span> <span class="static declaration mutable">STATIC_MUT</span>: <span class="builtin_type">i32</span> = <span class="numeric_literal">0</span>;
|
||||
|
||||
<span class="keyword">fn</span> <span class="function declaration">foo</span><<span class="lifetime declaration">'a</span>, <span class="type_param declaration">T</span>>() -> <span class="type_param">T</span> {
|
||||
|
|
|
@ -403,13 +403,13 @@ fn highlight_element(
|
|||
T![break]
|
||||
| T![continue]
|
||||
| T![else]
|
||||
| T![for]
|
||||
| T![if]
|
||||
| T![loop]
|
||||
| T![match]
|
||||
| T![return]
|
||||
| T![while]
|
||||
| T![in] => h | HighlightModifier::ControlFlow,
|
||||
T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow,
|
||||
T![unsafe] => h | HighlightModifier::Unsafe,
|
||||
_ => h,
|
||||
}
|
||||
|
@ -433,6 +433,13 @@ fn highlight_element(
|
|||
}
|
||||
}
|
||||
|
||||
fn is_child_of_impl(element: SyntaxElement) -> bool {
|
||||
match element.parent() {
|
||||
Some(e) => e.kind() == IMPL_DEF,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight {
|
||||
match def {
|
||||
Definition::Macro(_) => HighlightTag::Macro,
|
||||
|
|
|
@ -17,6 +17,16 @@ struct Foo {
|
|||
pub y: i32,
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
fn bar(&self) -> i32;
|
||||
}
|
||||
|
||||
impl Bar for Foo {
|
||||
fn bar(&self) -> i32 {
|
||||
self.x
|
||||
}
|
||||
}
|
||||
|
||||
static mut STATIC_MUT: i32 = 0;
|
||||
|
||||
fn foo<'a, T>() -> T {
|
||||
|
|
Loading…
Reference in a new issue