about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2025-03-12Rollup merge of #138318 - lolbinarycat:rustdoc-js-less-expect-error-part2, ↵Manish Goregaokar-37/+52
r=notriddle Rustdoc: remove a bunch of @ts-expect-error from main.js r? ```````@notriddle``````` Most remaining instances of ````````@ts-expect-error```````` in `search.js` and `main.js` are some sort of unchecked assertion, most of them involving nullibility, and we have yet to decide on how to handle these.
2025-03-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-17/+16
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-03-11Auto merge of #128440 - oli-obk:defines, r=lcnrbors-1/+1
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed. A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table. Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable. Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature. One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now. fixes #131298
2025-03-11Implement `#[define_opaque]` attribute for functions.Oli Scherer-1/+1
2025-03-10main.js: remove searchState from globals.binarycat-1/+1
2025-03-10main.js: typecheck things related to window.register_type_implsbinarycat-8/+10
2025-03-10rustdoc.d.ts: add window.{register_implementors,pending_implementors}binarycat-3/+17
2025-03-10rustdoc.d.ts: window.SIDEBAR_ITEMS may exist.binarycat-1/+2
2025-03-10main.js: handle document.activeElement being nullbinarycat-2/+2
this is technically possible if someone sticks rustdoc in an iframe, i think?
2025-03-10main.js(isDisplayed): coerce truthy values to booleanbinarycat-3/+2
2025-03-10main.js: always refer to searchState through window.searchStatebinarycat-10/+5
2025-03-10main.js: handleEscape and handleShortcut accept KeyboardEventbinarycat-2/+6
2025-03-10main.js: give type signatures to a few helper functionsbinarycat-4/+8
2025-03-10main.js: don't set mouseMovedAfterSearch, as it is never readbinarycat-1/+0
2025-03-10main.js: insertAfter needs non-root referenceNodebinarycat-4/+1
2025-03-10Rollup merge of #138281 - saethlin:mergeable-doctests-stacksize, ↵Matthias Krüger-9/+10
r=GuillaumeGomez Fix O(tests) stack usage in edition 2024 mergeable doctests Fixes https://github.com/rust-lang/rust/issues/138248 The important change here is that we are not passing a potentially-large array by value. Between the fact that `TestFn` cannot be `Clone` and `test_main` takes a `Vec<TestDescAndFn>`, the only way to call `test::test_main` without O(tests) stack use is to call `Vec::push` many times. The normal test harness does not have this problem because it calls `test_main_static` or `test_main_static_abort`, which take `&[TestDescAndFn]`. Changing `test::test_main` to take a slice is not a simple change, so I'm avoiding doing it here.
2025-03-10Fix O(tests) stack usage in edition 2024 mergeable doctestsBen Kimock-9/+10
2025-03-10doctests: build test bundle and harness separatelyMichael Howell-62/+150
This prevents the included test case from getting at nightly-only features when run on stable. The harness builds with RUSTC_BOOTSTRAP, but the bundle doesn't.
2025-03-10doctests: fix merging on stableMichael Howell-1/+6
Fixes #137898 The generated multi-test harness relies on nightly-only APIs, so the only way to run it on stable is to enable them. Since tests that use crate attrs don't be merged, there's no way to use nightly-only features on it anyway.
2025-03-08Rollup merge of #137757 - estebank:trim-spans, r=davidtwcoJacob Pratt-1/+0
On long spans, trim the middle of them to make them fit in the terminal width When encountering a single line span that is wider than the terminal, we keep context at the start and end of the span but otherwise remove the code from the middle. This is somewhat independent from whether the left and right margins of the output have been trimmed as well. ``` error[E0308]: mismatched types --> $DIR/long-span.rs:6:15 | LL | ... = [0, 0, 0, 0, ..., 0, 0]; | ^^^^^^^^^^^^^...^^^^^^^ expected `u8`, found `[{integer}; 1681]` ``` Address part of https://github.com/rust-lang/rust/issues/137680 (missing handling of the long suggestion). Fix https://github.com/rust-lang/rust/issues/125581. --- Change the way that underline positions are calculated by delaying using the "visual" column position until the last possible moment, instead using the "file"/byte position in the file, and then calculating visual positioning as late as possible. This should make the underlines more resilient to non-1-width unicode chars. Unfortunately, as part of this change (which fixes some visual bugs) comes with the loss of some eager tab codepoint handling, but the output remains legible despite some minor regression on the "margin trimming" logic. --- `-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-07Rollup merge of #138150 - nnethercote:streamline-intravisit-visit_id, r=oli-obkMatthias Krüger-1/+1
Streamline HIR intravisit `visit_id` calls for items A small clean up.
2025-03-07Remove highlighting of spans on `-Zteach`Esteban Küber-1/+0
`-Zteach` is perma-unstable, barely used, the highlighting logic buggy and the flag being passed around is tech-debt. We should likely remove `-Zteach` in its entirely.
2025-03-07Rollup merge of #138111 - estebank:use-dfv, r=nnethercoteMatthias Krüger-2/+2
Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType` Wanted to see where `#![feature(default_field_values)]` could be used in the codebase. These three seemed like no-brainers. There are a bunch of more places where we could remove manual `Default` impls, but they `derive` other traits that rely on `syn`, which [doesn't yet support `default_field_values`](https://github.com/dtolnay/syn/issues/1774).
2025-03-07Rollup merge of #138107 - yotamofek:pr/rustdoc/clippy, r=GuillaumeGomezMatthias Krüger-49/+45
`librustdoc`: clippy fixes First commit is all machine-generated fixes, next two are some more lints fixed by hand/misc. cleanups Inspired by the redundant `.and_then()` added in https://github.com/rust-lang/rust/pull/137320 , and [this comment](https://github.com/rust-lang/rust/pull/138090#discussion_r1983111856) r? ```@GuillaumeGomez```
2025-03-07Move `visit_id` calls.Nicholas Nethercote-1/+1
In `walk_item`, we call `visit_id` on every item kind. For most of them we do it directly in `walk_item`. But for `ItemKind::Mod`, `ItemKind::Enum`, and `ItemKind::Use` we instead do it in the `walk_*` function called (via the `visit_*` function) from `walk_item`. I can see no reason for this inconsistency, so this commit makes those three cases like all the other cases, moving the `visit_id` calls into `walk_item`. This also avoids the need for a few `HirId` arguments.
2025-03-07Auto merge of #138127 - compiler-errors:rollup-kcarqrz, r=compiler-errorsbors-220/+203
Rollup of 17 pull requests Successful merges: - #137827 (Add timestamp to unstable feature usage metrics) - #138041 (bootstrap and compiletest: Use `size_of_val` from the prelude instead of imported) - #138046 (trim channel value in `get_closest_merge_commit`) - #138053 (Increase the max. custom try jobs requested to `20`) - #138061 (triagebot: add a `compiler_leads` ad-hoc group) - #138064 (Remove - from xtensa targets cpu names) - #138075 (Use final path segment for diagnostic) - #138078 (Reduce the noise of bootstrap changelog warnings in --dry-run mode) - #138081 (Move `yield` expressions behind their own feature gate) - #138090 (`librustdoc`: flatten nested ifs) - #138092 (Re-add `DynSend` and `DynSync` impls for `TyCtxt`) - #138094 (a small borrowck cleanup) - #138098 (Stabilize feature `const_copy_from_slice`) - #138103 (Git ignore citool's target directory) - #138105 (Fix broken link to Miri intrinsics in documentation) - #138108 (Mention me (WaffleLapkin) when changes to `rustc_codegen_ssa` occur) - #138117 ([llvm/PassWrapper] use `size_t` when building arg strings) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-06Rollup merge of #137534 - xizheyin:issue-137342, r=GuillaumeGomezMichael Goulet-2/+20
[rustdoc] hide item that is not marked as doc(inline) and whose src is doc(hidden) Part of #137342 ![image](https://github.com/user-attachments/assets/68b4649a-a64a-43b2-8a73-6ac92b486e9e)
2025-03-06Manual, post-`clippy --fix` cleanupsYotam Ofek-23/+18
2025-03-06Implement `Ord` by-hand instead of `PartialOrd` for `Link`Yotam Ofek-6/+12
2025-03-06`x clippy src/librustdoc --fix`Yotam Ofek-29/+24
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-220/+203
2025-03-05Auto merge of #138031 - workingjubilee:rollup-5bsotpz, r=workingjubileebors-45/+41
Rollup of 15 pull requests Successful merges: - #137829 (Stabilize [T]::split_off... methods) - #137850 (Stabilize `box_uninit_write`) - #137912 (Do not recover missing lifetime with random in-scope lifetime) - #137913 (Allow struct field default values to reference struct's generics) - #137923 (Simplify `<Postorder as Iterator>::size_hint`) - #137949 (Update MSVC INSTALL.md instructions to recommend VS 2022 + recent Windows 10/11 SDK) - #137963 (Add ``dyn`` keyword to `E0373` examples) - #137975 (Remove unused `PpMode::needs_hir`) - #137981 (rustdoc search: increase strictness of typechecking) - #137986 (Fix some typos) - #137991 (Add `avr-none` to SUMMARY.md and platform-support.md) - #137993 (Remove obsolete comment from DeduceReadOnly) - #137996 (Revert "compiler/rustc_data_structures/src/sync/worker_local.rs: delete "unsafe impl Sync"") - #138019 (Pretty-print `#[deprecated]` attribute in HIR.) - #138026 (Make CrateItem::body() function return an option) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-04Rollup merge of #137981 - lolbinarycat:rustdoc-js-less-expect-error, r=notriddleJubilee-45/+41
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.
2025-03-04search.js: remove incorrect outdated commentbinarycat-2/+0
2025-03-04search.js: give RawSearchIndexCrate.a an index signaturebinarycat-4/+2
2025-03-04search.js: allow empty result arraysbinarycat-4/+3
2025-03-04search.js: give buildIndex a proper return typebinarycat-2/+5
some of the fields of rustdoc.Row were confusing null and undefined.
2025-03-04search.js: give local `where` a typebinarycat-2/+1
2025-03-04give local mgens a typebinarycat-2/+1
2025-03-04search.js: give pathSplitter a type signaturebinarycat-1/+5
2025-03-04search.js: second argument of convertNameToId is optionalbinarycat-2/+1
2025-03-04search.js: local variable `extra` is an array, annotate it as such.binarycat-2/+2
2025-03-04don't use double quotesbinarycat-1/+1
2025-03-04fix whitespacebinarycat-6/+6
2025-03-04Adapt `librustdoc` to 2024 edition lifetieme capture rulesYotam Ofek-420/+270
Get rid of the `Captures` hack
2025-03-04`librustdoc`: 2024 edition! 🎊Yotam Ofek-17/+18
2025-03-04ParserQueryElement.typeFilter MAY be a string, OR number.binarycat-4/+2
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.
2025-03-04rustdoc search: give buildTypeMapIndex a conditional return typebinarycat-16/+10
we encode "if the argument is a non-empty string, this will never return null" into the type signature.
2025-03-03rustdoc search: increase strictness of typecheckingbinarycat-6/+11
2025-03-04Auto merge of #137959 - matthiaskrgr:rollup-62vjvwr, r=matthiaskrgrbors-9/+4
Rollup of 12 pull requests Successful merges: - #135767 (Future incompatibility warning `unsupported_fn_ptr_calling_conventions`: Also warn in dependencies) - #137852 (Remove layouting dead code for non-array SIMD types.) - #137863 (Fix pretty printing of unsafe binders) - #137882 (do not build additional stage on compiler paths) - #137894 (Revert "store ScalarPair via memset when one side is undef and the other side can be memset") - #137902 (Make `ast::TokenKind` more like `lexer::TokenKind`) - #137921 (Subtree update of `rust-analyzer`) - #137922 (A few cleanups after the removal of `cfg(not(parallel))`) - #137939 (fix order on shl impl) - #137946 (Fix docker run-local docs) - #137955 (Always allow rustdoc-json tests to contain long lines) - #137958 (triagebot.toml: Don't label `test/rustdoc-json` as A-rustdoc-search) r? `@ghost` `@rustbot` modify labels: rollup