for purely return-type based searches, deprioritize clone-like functions by lolbinarycat · Pull Request #135302 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation35 Commits1 Checks6 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

lolbinarycat

@rustbot

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.

labels

Jan 9, 2025

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

tgross35

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

notriddle

@rustbot rustbot 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, 2025

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat

@notriddle do you know how to make console.log print to node's stdout? the stack traces aren't very helpful due to minification messing up all the line numbers.

@lolbinarycat

update: looks like the issue was the minification was stripping the log statements, hacking my way around the minification fixed that

@lolbinarycat

second update: the workaround broke things catestrophically: #135345

@notriddle

I've usually worked around it by running the test case in a browser instead of the test harness. The docs for a tests/rustdoc-js/type-parameters.rs, for example, can be opened with

firefox build/x86_64-unknown-linux-gnu/test/rustdoc-js/type-parameters/foo/index.html

This way, search.js can be symlinked like normal, and you can try out queries against the test data without having to re-run the test harness.

@lolbinarycat

fair... but honestly i really just want to bring back --disable-minification (and have opened a PR doing just that)

i also really don't know what's going on here, to be honest. i feel like i'm doing everything right, but evidently i'm not.

@notriddle

Do you mean the change to tests/rustdoc-js/type-parameters.js? Because I think that's a real change. alef gets sorted first because it thinks bet and beta are Clone-like (bet has two different generics, but they both unify with generic:T because they're being checked separately).

@lolbinarycat

well, mainly that sometimes i get a test failure when running locally (the one you fixed with type.where_clause, maybe there was a cache invalidation issue).

but anyways, i don't really think this should count generics, is there some way to turn off generic unification? maybe in one of those callbacks i don't really understand?

@notriddle

This code only fires if there's at least one item in the return spot. Check if any of them have a negative id number. If any of them do, that's a generic.

@lolbinarycat

but in the case of a search like -> SomeType, i don't want a function like T -> SomeTime to get deprioritized.

also, the code also triggers when sorting the "in return types" section.

@lolbinarycat

an example of a type that should not be considered clone-like is type_name_of_val

@lolbinarycat

ok it looks like that's not how generic unification works (right, they're universally quantified, not existentially), so the fix you recommended should work.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

notriddle

@lolbinarycat

Thanks again... I'm too used to having a typechecker, so I didn't even consider this as a possibility (I mean, even python would give a TypeError there)

GuillaumeGomez

* @param {[FunctionType]} where_clause - Trait bounds for generic items.
*/
function containsTypeFromQuery(list, where_clause) {
if (!list) return false;

Choose a reason for hiding this comment

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

Please add parens (here an below) for coherency with the rest of the code.

@GuillaumeGomez

Once ready, please squash your commits as well.

And final point: should we start documenting how search items are ranked and (de)prioritized in the rustdoc book?

@lolbinarycat

i think adding a section in the rustdoc book about how results are sorted would be a good idea, yes

@lolbinarycat @notriddle

A clone-like function in a function that takes as an argument the type that it returns.

However, functions that return a type variable are not counted as clone-line. Because we're not unifying the whole function at once, a function like U -> T would otherwise be counted as "clone-like" because the generics will just unify with anything when done seperatly.

Co-authored-by: Michael Howell michael@notriddle.com

@notriddle

@bors

📌 Commit ebd5ce1 has been approved by notriddle

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jan 14, 2025

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jan 14, 2025

@matthiaskrgr

…-sort-134935, r=notriddle

for purely return-type based searches, deprioritize clone-like functions

closes rust-lang#134935

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jan 14, 2025

@matthiaskrgr

…-sort-134935, r=notriddle

for purely return-type based searches, deprioritize clone-like functions

closes rust-lang#134935

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jan 15, 2025

@bors

…iaskrgr

Rollup of 7 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jan 15, 2025

@bors

…kingjubilee

Rollup of 11 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jan 15, 2025

@rust-timer

Rollup merge of rust-lang#135302 - lolbinarycat:rustdoc-search-return-sort-134935, r=notriddle

for purely return-type based searches, deprioritize clone-like functions

closes rust-lang#134935

Labels

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-rustdoc

Relevant to the rustdoc team, which will review and decide on the PR/issue.