Skip to content

Commit df3d3d8

Browse files
bors[bot]Veykril
andauthored
Merge #11175
11175: fix: Fix highlighting hack for self-params r=Veykril a=Veykril Fixes #11174 bors r+ Co-authored-by: Lukas Wirth <[email protected]>
2 parents 989c06b + 087122a commit df3d3d8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ide/src/syntax_highlighting/highlight.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,11 +712,13 @@ fn parent_matches<N: AstNode>(token: &SyntaxToken) -> bool {
712712
token.parent().map_or(false, |it| N::can_cast(it.kind()))
713713
}
714714

715-
fn is_in_fn_with_self_param<N: AstNode>(node: &N) -> bool {
715+
fn is_in_fn_with_self_param(node: &ast::NameRef) -> bool {
716716
node.syntax()
717717
.ancestors()
718-
.take_while(|node| ast::Expr::can_cast(node.kind()) || ast::Fn::can_cast(node.kind()))
719-
.find_map(ast::Fn::cast)
720-
.and_then(|s| s.param_list()?.self_param())
718+
.find_map(ast::Item::cast)
719+
.and_then(|item| match item {
720+
ast::Item::Fn(fn_) => fn_.param_list()?.self_param(),
721+
_ => None,
722+
})
721723
.is_some()
722724
}

0 commit comments

Comments
 (0)