Tag yield and await as ControlFlow in semantic highlighting

This commit is contained in:
Lukas Wirth 2021-04-23 16:43:48 +02:00
parent 85bab7539a
commit c005ce60a0
2 changed files with 13 additions and 5 deletions

View File

@ -254,15 +254,17 @@ pub(super) fn element(
k if k.is_keyword() => {
let h = Highlight::new(HlTag::Keyword);
match k {
T![break]
T![await]
| T![break]
| T![continue]
| T![else]
| T![if]
| T![in]
| T![loop]
| T![match]
| T![return]
| T![while]
| T![in] => h | HlMod::ControlFlow,
| T![yield] => h | HlMod::ControlFlow,
T![for] if !is_child_of_impl(&element) => h | HlMod::ControlFlow,
T![unsafe] => h | HlMod::Unsafe,
T![true] | T![false] => HlTag::BoolLiteral.into(),

View File

@ -47,21 +47,27 @@ pub enum HlMod {
/// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is
/// not.
Definition,
/// Doc-strings like this one.
Documentation,
/// Highlighting injection like rust code in doc strings or ra_fixture.
Injected,
/// Mutable binding.
Mutable,
/// Value that is being consumed in a function call
Consuming,
/// Callable item or value.
Callable,
/// Used for associated functions
/// Used for associated functions.
Static,
/// Used for items in impls&traits.
/// Used for items in traits and impls.
Associated,
/// Used for intra doc links in doc injection.
IntraDocLink,
/// Used for items in traits and trait impls.
Trait,
/// Keep this last!
// Keep this last!
/// Used for unsafe functions, mutable statics, union accesses and unsafe operations.
Unsafe,
}