Skip to content

Add notable_trait predicate to CompletionRelevance #16274

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

Merged
merged 2 commits into from
Jan 10, 2024

Conversation

dfireBird
Copy link
Contributor

Given a score of 1 for now, will change as per reviews needed.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 6, 2024
implement the predicate set on the case function from traits
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.

Let's add a test to crates\ide-completion\src\render.rs that checks that the relevance fetching works

@@ -79,6 +79,11 @@ fn render(
.and_then(|trait_| trait_.containing_trait_or_trait_impl(ctx.db()))
.map_or(false, |trait_| completion.is_ops_trait(trait_));

let is_item_from_notable_trait = func
.as_assoc_item(ctx.db())
Copy link
Member

Choose a reason for hiding this comment

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

Let's bind the as_assoc_item result to var and re-use that as multiple things in this function are interested in it (and the call is not completely free as it accesses the database)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay, if bind the result of the and_then as well, since seems like that's call to the db as well? I assume both methods (containing_trait and containing_trait_or_trait_impl) return the needed Trait.

Also is ctx.db() same as the db in the parameter of the render function?

Copy link
Member

Choose a reason for hiding this comment

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

The db is the same ye. You can (and actually want) to use containing_trait_or_trait_impl for both here, I missed that actually (since the attribuite is only on the trait, not trait impls).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the same too but just now saw the implementation and figured to ask the question.

@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 Jan 10, 2024
@dfireBird
Copy link
Contributor Author

My bad that I didn't add tests. If there any more checks to be made on tests, please suggest them. I will add it.

@Veykril
Copy link
Member

Veykril commented Jan 10, 2024

My bad that I didn't add tests. If there any more checks to be made on tests, please suggest them. I will add it.

No worries, I tend to forget to add tests myself from time to time. That one should suffice I think.

Thanks!
@bors r+

@bors
Copy link
Contributor

bors commented Jan 10, 2024

📌 Commit 257870e has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 10, 2024

⌛ Testing commit 257870e with merge b201684...

@bors
Copy link
Contributor

bors commented Jan 10, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing b201684 to master...

@bors bors merged commit b201684 into rust-lang:master Jan 10, 2024
@dfireBird dfireBird deleted the completion_score branch January 10, 2024 12:03
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