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

rustdoc search: increase strictness of typechecking #137981

Merged
merged 14 commits into from
Mar 5, 2025

Conversation

lolbinarycat
Copy link
Contributor

@lolbinarycat lolbinarycat commented Mar 4, 2025

r? @notriddle

The signature of makePrimitiveElement is now more accurate.

I believe the intent of the code is that name cannot be null if bindingName.name is null, and I believe typescript is expressive enough to encode this, but I'm not quite sure how, or if this would be desirable.

I'm also introducing mapped types into rustdoc.d.ts, but I think it's worth it in order to avoid keeping two interfaces in sync.

I may add more commits onto this to remove more @ts-expect-error instances.

@rustbot rustbot added A-rustdoc-search Area: Rustdoc's search feature 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Mar 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Mar 4, 2025

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha

we encode "if the argument is a non-empty string,
this will never return null" into the type signature.
@rust-log-analyzer

This comment has been minimized.

ideally we would encode that it is a string before
convertTypeFilterOnElem is called, and a number after,
but i'm not sure that's possible without significant refactoring.
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat
Copy link
Contributor Author

some of the fields of rustdoc.Row were confusing null and undefined.
@notriddle
Copy link
Contributor

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 4, 2025

📌 Commit 4f6772d 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-review Status: Awaiting review from the assignee but also interested parties. labels Mar 4, 2025
@notriddle
Copy link
Contributor

For "bool-returning closures," do you mean the onEach and onEachLazy callbacks? Or something else?

@lolbinarycat
Copy link
Contributor Author

@notriddle those, but also onEachBtwn.

also oops, I pushed more changes before I saw the approval, sorry.

@lolbinarycat
Copy link
Contributor Author

if i un-push the changes, will the approval re-activate?

@lolbinarycat lolbinarycat force-pushed the rustdoc-js-less-expect-error branch from 8920167 to 4f6772d Compare March 4, 2025 22:00
@lolbinarycat
Copy link
Contributor Author

doesn't look like it (also wow github does not seem to like me rewinding and replaying the PR)

@lolbinarycat
Copy link
Contributor Author

I'll leave this PR alone now, so you can properly review it.

@lolbinarycat
Copy link
Contributor Author

@notriddle CI is green again, sorry for the hassle.

@notriddle
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Mar 4, 2025

📌 Commit 8920167 has been approved by notriddle

It is now in the queue for this repository.

@@ -1586,7 +1573,6 @@ class DocSearch {
/**
* @type {Array<rustdoc.Row>}
*/
// @ts-expect-error
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for helping clean all this stuff up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, hopefully this should make things easier to maintain going forward.

I always planned on working on the migration if typescript got the ok, you just went and implemented half of it before I could do anything :p

I was a bit worried you were going to be put off by some of the conditional type wizardry, since it's doing things that the rust type system can't.

Copy link
Contributor

Choose a reason for hiding this comment

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

Rust doesn't have literal types, conditional types, or overloading.

But TypeScript can't do this, because type parameters are erased.

my_function(my_iterator.collect())
                     // ^^^^^^^ magically uses the correct `FromIterator`

I don't want to hammer that square peg into Rust's round hole. Writing in JS means giving up some power while accepting power elsewhere.

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 5, 2025
…kingjubilee

Rollup of 15 pull requests

Successful merges:

 - rust-lang#137829 (Stabilize [T]::split_off... methods)
 - rust-lang#137850 (Stabilize `box_uninit_write`)
 - rust-lang#137912 (Do not recover missing lifetime with random in-scope lifetime)
 - rust-lang#137913 (Allow struct field default values to reference struct's generics)
 - rust-lang#137923 (Simplify `<Postorder as Iterator>::size_hint`)
 - rust-lang#137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK)
 - rust-lang#137963 (Add ``dyn`` keyword to `E0373` examples)
 - rust-lang#137975 (Remove unused `PpMode::needs_hir`)
 - rust-lang#137981 (rustdoc search: increase strictness of typechecking)
 - rust-lang#137986 (Fix some typos)
 - rust-lang#137991 (Add `avr-none` to SUMMARY.md and platform-support.md)
 - rust-lang#137993 (Remove obsolete comment from DeduceReadOnly)
 - rust-lang#137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"")
 - rust-lang#138019 (Pretty-print `#[deprecated]` attribute in HIR.)
 - rust-lang#138026 (Make CrateItem::body() function return an option)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c32124f into rust-lang:master Mar 5, 2025
7 of 12 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 5, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Mar 5, 2025
Rollup merge of rust-lang#137981 - lolbinarycat:rustdoc-js-less-expect-error, r=notriddle

rustdoc search: increase strictness of typechecking

r? `@notriddle`

The signature of `makePrimitiveElement` is now more accurate.

I believe the intent of the code is that `name` cannot be null if `bindingName.name` is null, and I believe typescript is expressive enough to encode this, but I'm not quite sure how, or if this would be desirable.

I'm also introducing mapped types into `rustdoc.d.ts`, but I think it's worth it in order to avoid keeping two interfaces in sync.

I may add more commits onto this to remove more ``@ts-expect-error`` instances.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants