Skip to content

Commit 9a2db55

Browse files
committed
Support underscore suffix parameter hide inlayHints
Using suffix underscores to avoid keywords is one of the common skill, and inlayHints hiding should support it Example --- **Before this PR**: ```rust fn far(loop_: u32) {} fn faz(r#loop: u32) {} let loop_level = 0; far(loop_level); //^^^^^^^^^^ loop_ faz(loop_level); ``` **After this PR**: ```rust fn far(loop_: u32) {} fn faz(r#loop: u32) {} let loop_level = 0; far(loop_level); faz(loop_level); ```
1 parent 63f3646 commit 9a2db55

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/tools/rust-analyzer/crates/ide/src/inlay_hints/param_name.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ fn should_hide_param_name_hint(
124124
// hide when:
125125
// - the parameter name is a suffix of the function's name
126126
// - the argument is a qualified constructing or call expression where the qualifier is an ADT
127-
// - exact argument<->parameter match(ignoring leading underscore) or parameter is a prefix/suffix
128-
// of argument with _ splitting it off
127+
// - exact argument<->parameter match(ignoring leading and trailing underscore) or
128+
// parameter is a prefix/suffix of argument with _ splitting it off
129129
// - param starts with `ra_fixture`
130130
// - param is a well known name in a unary function
131131

132-
let param_name = param_name.trim_start_matches('_');
132+
let param_name = param_name.trim_matches('_');
133133
if param_name.is_empty() {
134134
return true;
135135
}
@@ -540,6 +540,8 @@ fn enum_matches_param_name(completion_kind: CompletionKind) {}
540540
fn foo(param: u32) {}
541541
fn bar(param_eter: u32) {}
542542
fn baz(a_d_e: u32) {}
543+
fn far(loop_: u32) {}
544+
fn faz(r#loop: u32) {}
543545
544546
enum CompletionKind {
545547
Keyword,
@@ -590,6 +592,9 @@ fn main() {
590592
let param_eter2 = 0;
591593
bar(param_eter2);
592594
//^^^^^^^^^^^ param_eter
595+
let loop_level = 0;
596+
far(loop_level);
597+
faz(loop_level);
593598
594599
non_ident_pat((0, 0));
595600

0 commit comments

Comments
 (0)