summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2025-08-01rustdoc: don't treat methods under const impls or traits as constDeadbeef-1/+14
2025-07-17Fix rustdoc not correctly showing attributes with re-exportsJonathan Brouwer-1/+2
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com> (cherry picked from commit 58418d881a91e9f37b0c8fd07f0218850725efda)
2025-06-22Port `#[no_mangle]` to new attribute parsing infrastructureJonathan Brouwer-12/+10
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-22Remove some dead code.Nicholas Nethercote-14/+0
We currently have both `FromClean<clean::Constant> for Constant` and `FromClean<clean::ConstantKind> for Constant` which are basically identical, but the former is unused.
2025-06-19De-dup common code from `ExternalCrate` methodsYotam Ofek-70/+52
2025-06-16rustdoc: skip `MetaSized` boundsDavid Wood-7/+52
These should never be shown to users at the moment.
2025-06-13Rollup merge of #142158 - xizheyin:141617, r=jdonszelmannMatthias Krüger-1/+1
Tracking the old name of renamed unstable library features This PR resolves the first problem of rust-lang/rust#141617 : tracking renamed unstable features. The first commit is to add a ui test, and the second one tracks the changes. I will comment on the code for clarification. r? `@jdonszelmann` There have been a lot of PR's reviewed by you lately, thanks for your time! cc `@jyn514`
2025-06-13Rollup merge of #141770 - GuillaumeGomez:cfg-false-mod-rendering, r=camelidMatthias Krüger-13/+16
Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common code Follow-up of https://github.com/rust-lang/rust/pull/141747. Thanks `@camelid` for spotting it! r? `@camelid`
2025-06-12Tracking the old name of renamed unstable library attributexizheyin-1/+1
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-10rustdoc: Refractor `clean_ty_generics`Alona Enraght-Moony-74/+19
2025-06-08Rollup merge of #142053 - heiher:loong32-none, r=wesleywiserJubilee-0/+1
Add new Tier-3 targets: `loongarch32-unknown-none*` MCP: https://github.com/rust-lang/compiler-team/issues/865 NOTE: LoongArch32 ELF object support is available starting with object v0.37.0.
2025-06-06Add new Tier-3 targets: `loongarch32-unknown-none*`WANG Rui-0/+1
MCP: https://github.com/rust-lang/compiler-team/issues/865
2025-06-06Rollup merge of #142092 - fmease:rustdoc-alias-terms, r=GuillaumeGomezMatthias Krüger-104/+65
rustdoc: Support middle::ty associated const equality predicates again Fix intentional regression from PR rust-lang/rust#125076. Fixes rust-lang/rust#125092. Fixes rust-lang/rust#134775. CC rust-lang/rust#141368 (`EqPredicates` and rustdoc).
2025-06-05Support middle::ty assoc const eq predicates againLeón Orell Valerian Liehr-93/+53
2025-06-05Rename `should_show_cast` to `should_fully_qualify`León Orell Valerian Liehr-12/+13
2025-06-05Replace some `Option<Span>` with `Span` and use DUMMY_SP instead of NoneOli Scherer-1/+1
2025-06-03Overhaul `UsePath`.Nicholas Nethercote-2/+2
`UsePath` contains a `SmallVec<[Res; 3]>`. This holds up to three `Res` results, one per namespace (type, value, or macro). `lower_import_res` takes a `PerNS<Option<Res<NodeId>>>` result and lowers it into the `SmallVec`. This is pretty weird. The input `PerNS` makes it clear which `Res` belongs to which namespace, but the `SmallVec` throws that information away. And code that operates on the `SmallVec` tends to use iteration (or even just grabbing the first entry!) without knowing which namespace the `Res` belongs to. Even weirder! Also, `SmallVec` is an overly flexible type to use here, because it can contain any number of elements (even though it's optimized for 3 in this case). This commit changes `UsePath` so it also contains a `PerNS<Option<Res<HirId>>>`. This type preserves more information and is more self-documenting. The commit also changes a lot of the use sites to access the result for a particular namespace. E.g. if you're looking up a trait, it will be in the `Res` for the type namespace if it's present; it's silly to look in the `Res` for the value namespace or macro namespace. Overall I find the new code much easier to understand. However, some use sites still iterate. These now use `present_items` because that filters out the `None` results. Also, `redundant_pub_crate.rs` gets a bigger change. A `UseKind:ListStem` item gets no `Res` results, which means the old `all` call in `is_not_macro_export` would succeed (because `all` succeeds on an empty iterator) and the `ListStem` would be ignored. This is what we want, but was more by luck than design. The new code detects `ListStem` explicitly. The commit generalizes the name of that function accordingly. Finally, the commit also removes the `use_path` arena, because `PerNS<Option<Res>>` impls `Copy` (unlike `SmallVec`) and it can be allocated in the arena shared by all `Copy` types.
2025-05-31Rollup merge of #141740 - nnethercote:hir-ItemKind-field-order, r=fee1-deadMatthias Krüger-9/+9
Hir item kind field order A follow-up to rust-lang/rust#141675. r? `@fee1-dead`
2025-05-30* Merge `Cfg::render_long_html` and `Cfg::render_long_plain` methods common codeGuillaume Gomez-13/+16
* Fix invalid whitespace handling
2025-05-30Auto merge of #141765 - matthiaskrgr:rollup-4hug83b, r=matthiaskrgrbors-44/+4
Rollup of 5 pull requests Successful merges: - rust-lang/rust#141703 (Structurally normalize types as needed in `projection_ty_core`) - rust-lang/rust#141719 (Add tls_model for cygwin and enable has_thread_local) - rust-lang/rust#141736 (resolve stage0 sysroot from rustc) - rust-lang/rust#141746 (Rework `#[doc(cfg(..))]` checks as distinct pass in rustdoc) - rust-lang/rust#141749 (Remove RUSTC_RETRY_LINKER_ON_SEGFAULT hack) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-30Rollup merge of #141746 - Urgau:rework-doc_cfg-checks, r=GuillaumeGomezMatthias Krüger-44/+4
Rework `#[doc(cfg(..))]` checks as distinct pass in rustdoc This PR reworks how rustdoc calls `rustc_attr_parsing::cfg_matches` to be in a separate pass, instead of being wired-up in a ad-hoc way, which is causing problems in https://github.com/rust-lang/rust/pull/138907#issuecomment-2920026627. This un-does most part of https://github.com/rust-lang/rust/pull/140894, but the result is IMO much cleaner, easier to reason about, and most importantly no longer interfears with rust-lang/rust#138907. r? `@GuillaumeGomez`
2025-05-30Auto merge of #141573 - nnethercote:rustdoc-alloc-cleanups, r=camelidbors-14/+8
rustdoc: cleanups relating to allocations These commits generally clean up the code a bit and also reduce allocation rates a bit. r? `@camelid`
2025-05-30Rollup merge of #141747 - lolbinarycat:rustdoc-cfg-138112, r=GuillaumeGomezMatthias Krüger-3/+12
rustdoc: display doc(cfg(false)) properly before we had an extra 'on' that was ungramatical. fixes https://github.com/rust-lang/rust/issues/138112 this is what it looks like now: ![screenshot: Available nowhere](https://github.com/user-attachments/assets/e27b4990-09a7-4f13-8bcf-26d44c8c1bea)
2025-05-29rustdoc: display doc(cfg(false)) properlybinarycat-3/+12
before we had an extra 'on' that was ungramatical. fixes https://github.com/rust-lang/rust/issues/138112
2025-05-29Rework `#[doc(cfg(..))]` checks as distinct pass in rustdocUrgau-44/+4
2025-05-30Reorder fields in `hir::ItemKind` variants.Nicholas Nethercote-9/+9
Specifically `TyAlias`, `Enum`, `Struct`, `Union`. So the fields match the textual order in the source code. The interesting part of the change is in `compiler/rustc_hir/src/hir.rs`. The rest is extremely mechanical refactoring.
2025-05-27Rollup merge of #140894 - Urgau:check-cfg-rustdoc, r=GuillaumeGomezTrevor Gross-5/+39
Make check-cfg diagnostics work in `#[doc(cfg(..))]` This PR makes it so that the check-cfg `unexpected_cfgs` lint, is correctly emitted in `rustdoc`'s `#[doc(cfg(..))]`. This is achieved by adding a custom trait to `cfg_matches` (the method that emits the lint) which permits `rustc` and `rustdoc` to each have their way to emitting lints (via buffered lints/AST for `rustc` and via `TyCtxt`/HIR for `rustdoc`). The reason this is required is because buffered lints operates on the AST but `rustdoc` uses the HIR and by the time `rustdoc` calls `cfg_matches` we are way passed the point where buffered lints have been drain and emitted. Best reviewed commit by commit. r? `@jieyouxu` (for the compiler part) r? `@GuillaumeGomez` (for the rustdoc part)
2025-05-27Rename unpack to kindMichael Goulet-3/+3
2025-05-26rustdoc: use custom `CfgMatchesLintEmitter` to make check-cfg workUrgau-5/+39
2025-05-26Avoid some unnecessary cloning.Nicholas Nethercote-1/+1
2025-05-26Make `{Type,Path}::generics` return iterators.Nicholas Nethercote-13/+7
Instead of a `Vec`, to avoid some allocations.
2025-05-25Update to new APIGuillaume Gomez-1/+1
2025-05-25Improve codeGuillaume Gomez-5/+6
2025-05-25Tweak attribute rendering depending on wether or not it is a type aliasGuillaume Gomez-61/+68
2025-05-25Split `Item::attributes` method into threeGuillaume Gomez-67/+78
2025-05-25Unify rendering of type aliases without ADT itemsGuillaume Gomez-0/+13
2025-05-25Rename `clean::Enum::variants` method into `non_stripped_variants`Guillaume Gomez-1/+1
2025-05-23Rollup merge of #141369 - ↵Matthias Krüger-72/+23
yotamofek:pr/rustdoc/format_integer_with_underscore_sep, r=notriddle Simplify `format_integer_with_underscore_sep` Noticed that this helper fn only ever gets called with decimal-base-formatted ints, so can be simplified a lot by not trying to handle hex and octal radixes. Second commit is completely unrelated, just simplified some code I wrote a while back 😁
2025-05-23Small cleanup for `qpath_to_string`Yotam Ofek-9/+2
2025-05-23Simplify `format_integer_with_underscore_sep`Yotam Ofek-63/+21
Only ever needs to handle decimal reprs
2025-05-22rustdoc JSON: Don't apply `#[repr]` privacy heuristicsLeón Orell Valerian Liehr-15/+7
2025-05-19Rollup merge of #140874 - mejrs:rads, r=WaffleLapkinStuart Cook-6/+8
make `rustc_attr_parsing` less dominant in the rustc crate graph It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly. Previous graph: ![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd) Graph with this PR: ![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a) The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*. The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-18Remove rustc_attr_data_structures re-export from rustc_attr_parsingmejrs-6/+8
2025-05-17Make some `match`es slightly more ergonomic in `librustdoc`Yotam Ofek-56/+50
2025-05-09Remove `Ident::empty`.Nicholas Nethercote-1/+1
All uses have been removed. And it's nonsensical: an identifier by definition has at least one char. The commits adds an is-non-empty assertion to `Ident::new` to enforce this, and converts some `Ident` constructions to use `Ident::new`. Adding the assertion requires making `Ident::new` and `Ident::with_dummy_span` non-const, which is no great loss. The commit amends a couple of places that do path splitting to ensure no empty identifiers are created.
2025-05-07rustdoc-json: Remove newlines from attributesAlona Enraght-Moony-1/+5
2025-04-28Rollup merge of #140316 - nnethercote:BoxMarker, r=dtolnayGuillaume Gomez-4/+4
Introduce `BoxMarker` to improve pretty-printing correctness Box opening/closing is really easy to get wrong in the pretty-printers. This PR makes it much harder to get wrong. r? `@Urgau`
2025-04-28Introduce `BoxMarker` to pretty-printing.Nicholas Nethercote-4/+4
The pretty-printers open and close "boxes" of text a lot. The open and close operations must be matched. The matching is currently all implicit and very easy to get wrong. (#140280 and #140246 are two recent pretty-printing fixes that both involved unclosed boxes.) This commit introduces `BoxMarker`, a marker type that represents an open box. It makes box opening/closing explicit, which makes it much easier to understand and harder to get wrong. The commit also removes many comments are on `end` calls saying things like "end outer head-block", "Close the outer-box". These demonstrate how confusing the implicit approach was, but aren't necessary any more.
2025-04-24Remove `weak` alias terminologyBoxy-2/+2
2025-04-22Auto merge of #139897 - nnethercote:rm-OpenDelim-CloseDelim, r=petrochenkovbors-2/+2
Remove `token::{Open,Close}Delim` By replacing them with `{Open,Close}{Param,Brace,Bracket,Invisible}`. PR #137902 made `ast::TokenKind` more like `lexer::TokenKind` by replacing the compound `BinOp{,Eq}(BinOpToken)` variants with fieldless variants `Plus`, `Minus`, `Star`, etc. This commit does a similar thing with delimiters. It also makes `ast::TokenKind` more similar to `parser::TokenType`. This requires a few new methods: - `TokenKind::is_{,open_,close_}delim()` replace various kinds of pattern matches. - `Delimiter::as_{open,close}_token_kind` are used to convert `Delimiter` values to `TokenKind`. Despite these additions, it's a net reduction in lines of code. This is because e.g. `token::OpenParen` is so much shorter than `token::OpenDelim(Delimiter::Parenthesis)` that many multi-line forms reduce to single line forms. And many places where the number of lines doesn't change are still easier to read, just because the names are shorter, e.g.: ``` - } else if self.token != token::CloseDelim(Delimiter::Brace) { + } else if self.token != token::CloseBrace { ``` r? `@petrochenkov`