Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: don't show inlay hint when param name is a_b_c and argument expr is a.b.c #19039

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poliorcetics
Copy link
Contributor

For now this is an exact match, should it be a sub-match starting from the end (b_c would match *.b.c) ?

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 26, 2025
@ChayimFriedman2
Copy link
Contributor

How is that common? That seems to be pretty rare.

@poliorcetics
Copy link
Contributor Author

I see it quite often with a pattern like <item>.id passed to a function taking item_id: T

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem rather uncommon (unless your codebase has this specific naming pattern). Though I think itwould be fine to ignore _ and . generally here when comparing similarity? That is we can just change the eq_ignore_ascii_case with iterating the chars, ignoring . and _ chars and then eq_ignore_ascii_case the characters themselves. That would also work for your use case. (also adjust the comment explaining the heuristics)

@@ -154,6 +156,18 @@ fn is_param_name_suffix_of_fn_name(
}
}

/// `a_b_c_d` will match `a.b.c.d`
fn is_param_name_same_as_field_expr(argument: &ast::Expr, param_name: &str) -> bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be part of is_argument_similar_to_param_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't as it is: this is iterating the full field expression, whereas is_argument_similar_to_param_name uses only the last part of the field expr

I can modify it to take the whole expression in that case maybe ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, well at least move it to is_argument_expr_similar_to_param_name I'd say then, though given my other comment that might not be necessary either way

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants