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 }})
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 added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the rustdoc team, which will review and decide on the PR/issue.
labels
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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
This comment has been minimized.
@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.
update: looks like the issue was the minification was stripping the log statements, hacking my way around the minification fixed that
second update: the workaround broke things catestrophically: #135345
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.
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.
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).
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?
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.
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.
an example of a type that should not be considered clone-like is type_name_of_val
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.
This comment has been minimized.
This comment has been minimized.
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)
* @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.
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?
i think adding a section in the rustdoc book about how results are sorted would be a good idea, yes
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
📌 Commit ebd5ce1 has been approved by notriddle
It is now in the queue for this repository.
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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…-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
…-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
…iaskrgr
Rollup of 7 pull requests
Successful merges:
- rust-lang#134940 (Make sure to scrape region constraints from deeply normalizing type outlives assumptions in borrowck)
- rust-lang#135047 (Add gpu-kernel calling convention)
- rust-lang#135228 (Improve
DispatchFromDyn
andCoerceUnsized
impl validation) - rust-lang#135264 (Consider more erroneous layouts as
LayoutError::ReferencesError
to suppress spurious errors) - rust-lang#135302 (for purely return-type based searches, deprioritize clone-like functions)
- rust-lang#135380 (Make sure we can produce
ConstArgHasWrongType
errors for valtree consts) - rust-lang#135425 (Do not consider traits that have unsatisfied const conditions to be conditionally const)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…kingjubilee
Rollup of 11 pull requests
Successful merges:
- rust-lang#134913 (bootstrap: do not rely on LIBRARY_PATH env variable)
- rust-lang#134940 (Make sure to scrape region constraints from deeply normalizing type outlives assumptions in borrowck)
- rust-lang#135228 (Improve
DispatchFromDyn
andCoerceUnsized
impl validation) - rust-lang#135264 (Consider more erroneous layouts as
LayoutError::ReferencesError
to suppress spurious errors) - rust-lang#135302 (for purely return-type based searches, deprioritize clone-like functions)
- rust-lang#135353 (re-add --disable-minification to rustdoc)
- rust-lang#135380 (Make sure we can produce
ConstArgHasWrongType
errors for valtree consts) - rust-lang#135423 (Enforce syntactical stability of const traits in HIR)
- rust-lang#135425 (Do not consider traits that have unsatisfied const conditions to be conditionally const)
- rust-lang#135499 (fix underlining of hovered intra-doc links.)
- rust-lang#135505 (Fix clippy lints in rustdoc)
r? @ghost
@rustbot
modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
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
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the rustdoc team, which will review and decide on the PR/issue.