about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2025-07-22Introduce `Symbol::with_interner`.Nicholas Nethercote-21/+29
It lets you get the contents of multiple symbols with a single TLS lookup and interner lock, instead of one per symbol.
2025-07-20Rollup merge of #143988 - GuillaumeGomez:alias-inexact, r=lolbinarycatMatthias Krüger-74/+85
[rustdoc] Make aliases search support partial matching Fixes rust-lang/rust#140782. To make this work, I moved aliases into the `searchIndex` like any other item. It links to the "original" item with a new `original` field. No so great part is that we need to have some fields like `bitIndex` to be set on the alias to make the description load to work but I consider it minor enough to be ok. This PR voluntarily doesn't handle de-prioritization of aliases as ```@lolbinarycat``` wished to work on this so I'll leave them this part. :wink: cc ```@lolbinarycat```
2025-07-19Add code comment explaining better what `Row.name` is for doc aliasesGuillaume Gomez-0/+2
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-174/+154
2025-07-17Include ErrorGuaranteed in StableSince::Err.Camille GILLOT-1/+1
2025-07-17parse `const trait Trait`Deadbeef-2/+2
2025-07-17Auto merge of #144044 - fmease:rollup-kg413pt, r=fmeasebors-57/+33
Rollup of 15 pull requests Successful merges: - rust-lang/rust#142304 (tests: Add `RUST_BACKTRACE` and `-Cpanic` revisions to `panic-main.rs` test) - rust-lang/rust#143388 (Various refactors to the LTO handling code) - rust-lang/rust#143409 (Enable xgot feature for mips64 musl targets) - rust-lang/rust#143592 (UWP: link ntdll functions using raw-dylib) - rust-lang/rust#143595 (add `const_make_global`; err for `const_allocate` ptrs if didn't call) - rust-lang/rust#143678 (Added error for invalid char cast) - rust-lang/rust#143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets) - rust-lang/rust#143829 (Trim `BorrowedCursor` API) - rust-lang/rust#143851 (ci cleanup: rustdoc-gui-test now installs browser-ui-test) - rust-lang/rust#143856 (Linting public reexport of private dependencies) - rust-lang/rust#143895 (Dont collect assoc ty item bounds from trait where clause for host effect predicates) - rust-lang/rust#143922 (Improve path segment joining) - rust-lang/rust#143964 (Fix handling of SCRIPT_ARG in docker images) - rust-lang/rust#144002 (Update poison.rs) - rust-lang/rust#144016 (trait_sel: `MetaSized` always holds temporarily) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-17Auto merge of #140399 - tiif:unstable_impl, r=lcnr,BoxyUwUbors-1/+2
Implement unstable trait impl This PR allows marking impls of stable trait with stable type as unstable. ## Approach In std/core, an impl can be marked as unstable by annotating it with ``#[unstable_feature_bound(feat_name)]``. This will add a ``ClauseKind::Unstable_Feature(feat_name)`` to the list of predicates in ``predicates_of`` . When an unstable impl's function is called, we will first iterate through all the goals in ``param_env`` to check if there is any ``ClauseKind::UnstableFeature(feat_name)`` in ``param_env``. The existence of ``ClauseKind::Unstable_Feature(feat_name)`` in ``param_env`` means an``#[unstable_feature_bound(feat_name)]`` is present at the call site of the function, so we allow the check to succeed in this case. If ``ClauseKind::UnstableFeature(feat_name)`` does not exist in ``param_env``, we will still allow the check to succeed for either of the cases below: 1. The feature is enabled through ``#[feature(feat_name)]`` outside of std / core. 2. We are in codegen because we may be monomorphizing a body from an upstream crate which had an unstable feature enabled that the downstream crate do not. For the rest of the case, it will fail with ambiguity. ## Limitation In this PR, we do not support: 1. using items that need ``#[unstable_feature_bound]`` within stable APIs 2. annotate main function with ``#[unstable_feature_bound]`` 3. annotate ``#[unstable_feature_bound]`` on items other than free function and impl ## Acknowledgement The design and mentoring are done by `@BoxyUwU`
2025-07-17Improve path segment joining.Nicholas Nethercote-57/+33
There are many places that join path segments with `::` to produce a string. A lot of these use `join("::")`. Many in rustdoc use `join_with_double_colon`, and a few use `.joined("..")`. One in Clippy uses `itertools::join`. A couple of them look for `kw::PathRoot` in the first segment, which can be important. This commit introduces `rustc_ast::join_path_{syms,ident}` to do the joining for everyone. `rustc_ast` is as good a location for these as any, being the earliest-running of the several crates with a `Path` type. Two functions are needed because `Ident` printing is more complex than simple `Symbol` printing. The commit also removes `join_with_double_colon`, and `estimate_item_path_byte_length` with it. There are still a handful of places that join strings with "::" that are unchanged. They are not that important: some of them are in tests, and some of them first split a path around "::" and then rejoin with "::". This fixes one test case where `{{root}}` shows up in an error message.
2025-07-16Make aliases search support partial matchingGuillaume Gomez-74/+83
2025-07-15rustdoc-json: Structured attributesAlona Enraght-Moony-61/+127
Implements https://www.github.com/rust-lang/rust/issues/141358. This has 2 primary benefits: 1. For rustdoc-json consumers, they no longer need to parse strings of attributes, but it's there in a structured and normalized way. 2. For rustc contributors, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on https://github.com/rust-lang/rust/issues/131229 without needing to bump `FORMAT_VERSION`. (Over time, as the attribute refractor continues, I expect we'll add new things to `rustdoc_json_types::Attribute`. But this can be done separately to the rustc changes).
2025-07-15Implement other logicstiif-1/+2
2025-07-14Rollup merge of #143875 - fee1-dead-contrib:push-zvqrmzrprpzt, r=compiler-errorsJakub Beránek-2/+2
update issue number for `const_trait_impl` r? project-const-traits cc rust-lang/rust#67792 rust-lang/rust#143874
2025-07-14Auto merge of #143779 - JonathanBrouwer:automatically_derived_parser, r=oli-obkbors-0/+3
Port `#[automatically_derived]` to the new attribute parsing infrastructure Ports `#[automatically_derived]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163 r? `@oli-obk` cc `@jdonszelmann`
2025-07-13update issue number for `const_trait_impl`Deadbeef-2/+2
2025-07-13Retire hir::*ItemRef.Camille GILLOT-3/+3
2025-07-13Retire hir::ForeignItemRef.Camille GILLOT-2/+2
2025-07-12Fix clippy & rustdoc-jsonJonathan Brouwer-0/+3
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-10Rollup merge of #143590 - GuillaumeGomez:reexport-shadowing, r=lolbinaryMatthias Krüger-40/+84
Fix weird rustdoc output when single and glob reexport conflict on a name Fixes rust-lang/rust#143107. The problem was that the second reexport would overwrite the first, leading to having unexpected results. To fix it, I now group items by their original `DefId` and their name and keep tracks of all imports for this item (should very rarely be more than one though, and even less often more than 2). cc `@lolbinarycat`
2025-07-08Rollup merge of #143555 - ↵Matthias Krüger-1/+14
obi1kenobi:pg/target-feature-not-unsafe-rustdoc-json, r=aDotInTheVoid Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON. Fixes https://github.com/rust-lang/rust/issues/142655 by explicitly checking whether functions are safe but using `#[target_feature]`, instead of relying on the `FnHeader::is_unsafe()` method which considers such functions unsafe. I don't believe this merits a bump of the rustdoc JSON `FORMAT_VERSION` constant, since the format is unchanged and this is just a small bugfix. r? aDotInTheVoid
2025-07-08Fix weird rustdoc output when single and glob reexport conflict on a nameGuillaume Gomez-40/+84
2025-07-08Auto merge of #142869 - nnethercote:join_path-mini, r=camelidbors-2/+2
Use `join_with_double_colon` in `write_shared.rs`. For consistency. Also, it's faster because `join_with_double_colon` does a better job estimating the allocation size than `join` from `itertools`. r? `@camelid`
2025-07-08Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.Predrag Gruevski-1/+14
2025-07-07Remove unused allow attrsYotam Ofek-2/+0
2025-07-07Rollup merge of #143544 - workingjubilee:rename-bare-fn, r=fmeaseJacob Pratt-2/+2
compiler: rename BareFn to FnPtr At some point "BareFn" was the chosen name for a "bare" function, without the niceties of `~fn`, `&fn`, or a few other ways of writing a function type. However, at some point the syntax for a "bare function" and any other function diverged even more. We started calling them what they are: function pointers, denoted by their own syntax. However, we never changed the *internal* name for these, as this divergence was very gradual. Personally, I have repeatedly searched for "FnPtr" and gotten confused until I find the name is BareFn, only to forget this until the next time, since I don't routinely interact with the higher-level AST and HIR. But even tools that interact with these internal types only touch on them in a few places, making a migration easy enough. Let's use a more intuitive and obvious name, as this 12+ year old name has little to do with current Rust.
2025-07-06rustdoc: migrate BareFn -> FnPtrJubilee Young-2/+2
2025-07-06Rewrite empty attribute lintJonathan Brouwer-1/+1
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-05Auto merge of #139598 - compiler-errors:no-bound-var-symbol, r=WaffleLapkinbors-47/+49
Remove `Symbol` from `Named` variant of `BoundRegionKind`/`LateParamRegionKind` The `Symbol` is redundant, since we already store a `DefId` in the region variant. Instead, load the name via `item_name` when needed (which is almost always on the diagnostic path). This introduces a `BoundRegionKind::NamedAnon` which is used for giving anonymous bound regions names, but which should only be used during pretty printing and error reporting.
2025-07-04Port `#[non_exhaustive]` to the new attribute parsing infrastructureJonathan Brouwer-1/+3
2025-07-04Same for typesMichael Goulet-2/+3
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-45/+46
2025-07-04Rollup merge of #143381 - fee1-dead-contrib:push-pzxuvlnymxpu, r=GuillaumeGomezJacob Pratt-1/+14
rustdoc: don't treat methods under const impls or traits as const Fixes rust-lang/rust#143071
2025-07-03Rollup merge of #141831 - lolbinarycat:rustdoc-extern-reexport-135092, ↵Guillaume Gomez-13/+26
r=GuillaumeGomez rustdoc: fix attrs of locally reexported foreign items fixes rust-lang/rust#135092 also tweaks a few outdated/misleading comments. r? `@GuillaumeGomez`
2025-07-03rustdoc: don't treat methods under const impls or traits as constDeadbeef-1/+14
2025-07-03Auto merge of #143363 - jdonszelmann:rollup-7cv1kql, r=jdonszelmannbors-26/+32
Rollup of 6 pull requests Successful merges: - rust-lang/rust#134006 (setup typos check in CI) - rust-lang/rust#142876 (Port `#[target_feature]` to new attribute parsing infrastructure) - rust-lang/rust#143038 (avoid suggesting traits from private dependencies) - rust-lang/rust#143083 (Fix rustdoc not correctly showing attributes on re-exports) - rust-lang/rust#143283 (document optional jobs) - rust-lang/rust#143329 (minicore: use core's `diagnostic::on_unimplemented` messages) Failed merges: - rust-lang/rust#143237 (Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-03Rollup merge of #143083 - JonathanBrouwer:rustdoc-fix, r=jdonszelmannJana Dönszelmann-1/+2
Fix rustdoc not correctly showing attributes on re-exports Fixes attributes not being shown correctly in rustdoc on re-exports Does this need to be backported to beta? r? ``@jdonszelmann``
2025-07-03Rollup merge of #143038 - Qelxiros:142676-private-dependency-traits, r=tgross35Jana Dönszelmann-2/+2
avoid suggesting traits from private dependencies fixes rust-lang/rust#142676 fixes rust-lang/rust#138191 r? ``@tgross35``
2025-07-03Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obkJana Dönszelmann-12/+17
Port `#[target_feature]` to new attribute parsing infrastructure Ports `target_feature` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197 r? ``@jdonszelmann``
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-11/+11
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03Auto merge of #142910 - yotamofek:pr/rustdoc/markdown-lazy-to-string, ↵bors-86/+83
r=GuillaumeGomez Lazy-ify some markdown rendering Seems to have a positive effect in my local perf runs 😍 r? `@GuillaumeGomez` if you're interested, otherwise feel free to reassign (would also love a perf run)
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-11/+11
2025-07-03Port `#[target_feature]` to the new attribute parsing infrastructureJonathan Brouwer-12/+17
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-02avoid suggesting traits from private dependenciesJeremy Smart-2/+2
2025-07-01Improve CSS for source code block line numbersGuillaume Gomez-68/+30
2025-06-29Port #[link_section] to the new attribute parsing infrastructureAnne Stijns-1/+4
2025-06-29Lazy-ify some markdown renderingYotam Ofek-86/+83
2025-06-29Don't try to guess how much to pre-allocateYotam Ofek-2/+2
Removing this heuristic doesn't show up as a regression in perf run
2025-06-29Rollup merge of #143155 - yotamofek:pr/rustdoc/housekeeping, r=GuillaumeGomezMatthias Krüger-12/+8
`librustdoc` house-keeping 🧹 This PR mostly removes a bunch of crate-level attributes that were added at some point, but then later on became unnecessary: - some `#[feature]` gates - some `#[allow]`s - a `#[recursion_limit]` Then I went ahead and sprinkled some tidy sorting on the remaining attrs, and `Cargo.toml`. Trying to give my anal retentiveness some peace of mind 😅
2025-06-28Rollup merge of #142987 - lolbinarycat:rustdoc-non_exhaustive-enum-v-142599, ↵Matthias Krüger-0/+1
r=GuillaumeGomez rustdoc: show attributes on enum variants mostly for #[non_exhaustive] unsure if there's any attributes we should take care to *not* include, it could use `render_code_attribute` and `is_non_exhaustive` instead, if that is a concern. fixes rust-lang/rust#142599
2025-06-28librustdoc: use tidy for sorting attrs and depsYotam Ofek-4/+8