Skip to content

Add notable_trait predicate to CompletionRelevance#16274

Merged
bors merged 2 commits into
rust-lang:masterfrom
dfireBird:completion_score
Jan 10, 2024
Merged

Add notable_trait predicate to CompletionRelevance#16274
bors merged 2 commits into
rust-lang:masterfrom
dfireBird:completion_score

Conversation

@dfireBird

Copy link
Copy Markdown
Member

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

@Veykril Veykril left a comment

Copy link
Copy Markdown
Member

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

.map_or(false, |trait_| completion.is_ops_trait(trait_));

let is_item_from_notable_trait = func
.as_assoc_item(ctx.db())

Copy link
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
Member 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
Copy Markdown
Member 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

Veykril commented Jan 10, 2024

Copy link
Copy Markdown
Member

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

bors commented Jan 10, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 257870e has been approved by Veykril

It is now in the queue for this repository.

@bors

bors commented Jan 10, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 257870e with merge b201684...

@bors

bors commented Jan 10, 2024

Copy link
Copy Markdown
Contributor

☀️ 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