diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-03 00:32:31 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 00:32:31 +0000 |
| commit | df3d3d8a74e9c4780cec9f6a2bd687406dade8af (patch) | |
| tree | 27388356cb998e2aa7029f872ef099a52b768693 | |
| parent | 989c06b25d7e9d5c10ce77831952cab7359d6ab2 (diff) | |
| parent | 087122ad1a67c13fda313b30bf5e0817a7bfd79e (diff) | |
| download | rust-df3d3d8a74e9c4780cec9f6a2bd687406dade8af.tar.gz rust-df3d3d8a74e9c4780cec9f6a2bd687406dade8af.zip | |
Merge #11175
11175: fix: Fix highlighting hack for self-params r=Veykril a=Veykril Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11174 bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
| -rw-r--r-- | crates/ide/src/syntax_highlighting/highlight.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 4a09d341f70..41b13170bb0 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -712,11 +712,13 @@ fn parent_matches<N: AstNode>(token: &SyntaxToken) -> bool { token.parent().map_or(false, |it| N::can_cast(it.kind())) } -fn is_in_fn_with_self_param<N: AstNode>(node: &N) -> bool { +fn is_in_fn_with_self_param(node: &ast::NameRef) -> bool { node.syntax() .ancestors() - .take_while(|node| ast::Expr::can_cast(node.kind()) || ast::Fn::can_cast(node.kind())) - .find_map(ast::Fn::cast) - .and_then(|s| s.param_list()?.self_param()) + .find_map(ast::Item::cast) + .and_then(|item| match item { + ast::Item::Fn(fn_) => fn_.param_list()?.self_param(), + _ => None, + }) .is_some() } |
