Merge #10859
10859: fix: Prioritize tuple fields in highlight_related r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
91cb422e1a
@ -10,7 +10,7 @@ use rustc_hash::FxHashSet;
|
|||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, HasLoopBody},
|
ast::{self, HasLoopBody},
|
||||||
match_ast, AstNode,
|
match_ast, AstNode,
|
||||||
SyntaxKind::IDENT,
|
SyntaxKind::{IDENT, INT_NUMBER},
|
||||||
SyntaxNode, SyntaxToken, TextRange, T,
|
SyntaxNode, SyntaxToken, TextRange, T,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -54,10 +54,9 @@ pub(crate) fn highlight_related(
|
|||||||
T![?] => 4, // prefer `?` when the cursor is sandwiched like in `await$0?`
|
T![?] => 4, // prefer `?` when the cursor is sandwiched like in `await$0?`
|
||||||
T![->] => 3,
|
T![->] => 3,
|
||||||
kind if kind.is_keyword() => 2,
|
kind if kind.is_keyword() => 2,
|
||||||
IDENT => 1,
|
IDENT | INT_NUMBER => 1,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
match token.kind() {
|
match token.kind() {
|
||||||
T![?] if config.exit_points && token.parent().and_then(ast::TryExpr::cast).is_some() => {
|
T![?] if config.exit_points && token.parent().and_then(ast::TryExpr::cast).is_some() => {
|
||||||
highlight_exit_points(sema, token)
|
highlight_exit_points(sema, token)
|
||||||
@ -346,6 +345,22 @@ mod tests {
|
|||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_hl_tuple_fields() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Tuple(u32, u32);
|
||||||
|
|
||||||
|
fn foo(t: Tuple) {
|
||||||
|
t.0$0;
|
||||||
|
// ^ read
|
||||||
|
t.0;
|
||||||
|
// ^ read
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_hl_module() {
|
fn test_hl_module() {
|
||||||
check(
|
check(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user