Conversation
|
Some changes occurred in HTML/CSS/JS. |
| if (v !== null) { | ||
| return v; | ||
| } | ||
| throw "rustdoc var " + name + " is missing"; |
There was a problem hiding this comment.
| throw "rustdoc var " + name + " is missing"; | |
| throw `rustdoc var "${name}" is missing`; |
| while (elem) { | ||
| if (elem.tagName === "DETAILS") { | ||
| // @ts-expect-error | ||
| if (elem instanceof HTMLDetailsElement) { |
There was a problem hiding this comment.
Although it's more correct, I find it so much less readable. ^^' (nothing to change here, just me sad that better code doesn't always look better)
| let methods = document.querySelector(".sidebar .block.method"); | ||
| let associatedTypes = document.querySelector(".sidebar .block.associatedtype"); | ||
| let associatedConstants = document.querySelector(".sidebar .block.associatedconstant"); | ||
|
|
There was a problem hiding this comment.
nitpick: any reason for this new line?
There was a problem hiding this comment.
Nope. will fix.
| } | ||
| } | ||
| const template = document.createElement("template"); | ||
| // @ts-expect-error |
There was a problem hiding this comment.
What error is expected here btw?
There was a problem hiding this comment.
string | 0 not assignable to string | null. this lead me to investigating TypeImpls generation and reading the code more thoroughly, which led me to realize only the second item in the array could be 0, thus the more complicated type definition.
| a.href = `#${nonnull(template.content.querySelector(".impl")).id}`; | ||
| // @ts-expect-error | ||
| a.href = `#${template.content.querySelector(".impl").id}`; | ||
| a.textContent = traitName; |
There was a problem hiding this comment.
Why does this one has expect-error now?
There was a problem hiding this comment.
It shouldn't, I think the intermediate commit got messed up by some rebasing.
There was a problem hiding this comment.
Ah, wait, I misread the diff, this is also Type 'string | 0' is not assignable to type 'string | null'., but this time the error is somewhat legitimate (well, it's a limitation of typescript not realizing that the value of isTrait is linked to the type of traitName)
There was a problem hiding this comment.
Can you add this as comment so future us will not have to search again for this explanation please?
There was a problem hiding this comment.
yeah will do. i originally didn't because i hoped i could find a way to get rid of it easily.
| mainContent.insertBefore(outputListHeader, trait_implementations_header); | ||
| mainContent.insertBefore(outputList, trait_implementations_header); | ||
| } else { | ||
| const mainContent = nonnull(document.querySelector("#main-content")); |
|
Apart from minor improvements, looks much better, thanks! |
197be7f to
519c0d9
Compare
This has two advantages: * removes a bunch of @ts-expect-error * typos of var names will cause type errors instead of runtime errors
|
Typing out "typescript doesn't understand this relation" made me wonder if I could make it understand, and the answer was yes, so... Instead of adding a comment explaining the |
this allows TypeScript to understand the relation between isTrait and traitName's type, getting rid of a type error.
| const text = impList[0]; | ||
| const isTrait = impList[1] !== 0; | ||
| const traitName = impList[1]; | ||
| const isTrait = typeof traitName === "string"; |
There was a problem hiding this comment.
That's not the same check at all. Is there a reason why we go from integer comparison to checking it's a string? (lack of context on my side here)
There was a problem hiding this comment.
impList[1] has type string | 0, so this is actually an equivalent check, though I could see how it could really not look like it without that context.
There was a problem hiding this comment.
I see. JS is weird and we really abuse it sometimes. XD
|
Thanks! @bors r+ rollup |
…=GuillaumeGomez rustdoc: more js cleanup Continuing the effort of removing `@ts-expect-error` from the codebase wherever possible, this time focusing on `main.js`. Found some oddities with `register_type_impls`, fixed most of them, but the one that I couldn't figure out is what's going on with `sidebarTraitList`. It's queried, then if there are any trait imps, unconditionally overwritten, then latter code assumes that one of these two things has initialized it, but it's not obvious why this would be the case, or if there's a reason this wasn't done in a more straightforwards way. r? @GuillaumeGomez
Rollup of 11 pull requests Successful merges: - #151998 (Set hidden visibility on naked functions in compiler-builtins) - #149460 (rustdoc: sort stable items first) - #152076 (Feed `ErrorGuaranteed` from late lifetime resolution errors through to bound variable resolution) - #152471 (improve associated-type suggestions from bounds) - #152573 (move `escape_symbol_name` to `cg_ssa`) - #152594 (c-variadic: implement `va_arg` for `wasm64`) - #151386 (rustdoc: more js cleanup) - #152567 (nix-dev-shell: fix a typo) - #152568 (Port `#[lang]` and `#[panic_handler]` to the new attribute parsers) - #152575 (layout_of unexpected rigid alias delayed bug) - #152587 (A couple of tiny polonius things)
Continuing the effort of removing
@ts-expect-errorfrom the codebase wherever possible, this time focusing onmain.js. Found some oddities withregister_type_impls, fixed most of them, but the one that I couldn't figure out is what's going on withsidebarTraitList. It's queried, then if there are any trait imps, unconditionally overwritten, then latter code assumes that one of these two things has initialized it, but it's not obvious why this would be the case, or if there's a reason this wasn't done in a more straightforwards way.r? @GuillaumeGomez