about summary refs log tree commit diff
path: root/src/librustdoc/clean
AgeCommit message (Collapse)AuthorLines
2025-10-02Move doc_cfg-specific code into `cfg.rs`Guillaume Gomez-264/+268
2025-09-29Rollup merge of #147133 - GuillaumeGomez:rm-loop-extract_cfg_from_attrs, ↵Matthias Krüger-11/+5
r=lolbinarycat Remove one loop in `extract_cfg_from_attrs` Follow-up of https://github.com/rust-lang/rust/pull/138907. r? lolbinarycat
2025-09-29Improve code commentsGuillaume Gomez-5/+3
2025-09-29Use `Iterator::eq` and (dogfood) `eq_by` in compiler and libraryYotam Ofek-1/+1
2025-09-28Remove one loop in `extract_cfg_from_attrs`Guillaume Gomez-8/+4
2025-09-27Improve code and fix typoGuillaume Gomez-6/+4
2025-09-27Improve code comments and extend tests for `doc_cfg` featureGuillaume Gomez-2/+4
2025-09-27Correctly handle target_feature in rustdoc cfgGuillaume Gomez-26/+11
2025-09-27Improve code and better check `doc(cfg(...))` attributesGuillaume Gomez-36/+57
2025-09-27Add code documentation, improve code and improve error messageGuillaume Gomez-0/+13
2025-09-27Rename `CfgInfo::doc_auto_cfg_active` into `auto_cfg_active`Guillaume Gomez-9/+9
2025-09-27Implement RFC 3631Guillaume Gomez-87/+270
2025-09-25Rollup merge of #116882 - fmease:rustdoc-generalized-priv-repr-heuristic, ↵Matthias Krüger-112/+0
r=rustdoc rustdoc: hide `#[repr]` if it isn't part of the public ABI > [!IMPORTANT] > Temporarily stacked on top of PR https://github.com/rust-lang/rust/pull/146527; only the last commit is relevant! Follow-up to rust-lang/rust#115439. Unblocks rust-lang/rust#116743, CC ``@dtolnay.`` Fixes rust-lang/rust#66401. Fixes rust-lang/rust#128364. Fixes rust-lang/rust#137440. Only display the representation `#[repr(REPR)]` (where `REPR` is not `Rust` or `transparent`) of a given type if none of its variants (incl. the synthetic variants of structs) are `#[doc(hidden)]` and all of its fields are public and not `#[doc(hidden)]` since it's likely not meant to be considered part of the public ABI otherwise. `--document-{private,hidden}-items` works as expected in this context, too. Moreover, we now also factor in the presence of `#[doc(hidden)]` when checking whether to show `repr(transparent)` or not.
2025-09-22Introduce "wrapper" helpers to rustdocYotam Ofek-48/+30
2025-09-17Remove `DynKind`León Orell Valerian Liehr-1/+1
2025-09-14rustdoc: Move HTML-specific attr rendering code into HTML rendering modLeón Orell Valerian Liehr-112/+0
These functions used to be shared with the JSON backend but nowadays they aren't.
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-1/+4
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-29/+24
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-14/+14
2025-09-09Strip frontmatter in fewer placesLeón Orell Valerian Liehr-8/+13
2025-09-01Remove dead code stemming from an old effects desugaringLeón Orell Valerian Liehr-5/+3
2025-08-28Create new `Item::is_fake_item` method as equivalent to check for ↵Guillaume Gomez-0/+11
`is_primitive`, `is_keyword` and `is_attribute` methods
2025-08-28Add new `doc(attribute = "...")` attributeGuillaume Gomez-7/+35
2025-08-25rustdoc(opt): build_impl: check document_private earlierbinarycat-17/+17
2025-08-22Add an experimental unsafe(force_target_feature) attribute.Luca Versari-1/+2
This uses the feature gate for https://github.com/rust-lang/rust/issues/143352, but is described in https://github.com/rust-lang/rfcs/pull/3820 which is strongly tied to the experiment.
2025-08-18Rollup merge of #144838 - Kivooeo:doc-subtype, r=notriddleStuart Cook-4/+4
Fix outdated doc comment This updates the documentation comment for `Type::is_doc_subtype_of` to more accurately describe its purpose as a subtyping check, rather than equality fixes rust-lang/rust#138572 r? ````````````@tgross35````````````
2025-08-13Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petrochenkovGuillaume Gomez-21/+46
Handle macros with multiple kinds, and improve errors (I recommend reviewing this commit-by-commit.) Switch to a bitflags `MacroKinds` to support macros with more than one kind Review everything that uses `MacroKind`, and switch anything that could refer to more than one kind to use `MacroKinds`. Add a new `SyntaxExtensionKind::MacroRules` for `macro_rules!` macros, using the concrete `MacroRulesMacroExpander` type, and have it track which kinds it can handle. Eliminate the separate optional `attr_ext`, now that a `SyntaxExtension` can handle multiple macro kinds. This also avoids the need to downcast when calling methods on `MacroRulesMacroExpander`, such as `get_unused_rule`. Integrate macro kind checking into name resolution's `sub_namespace_match`, so that we only find a macro if it's the right type, and eliminate the special-case hack for attributes. This allows detecting and report macro kind mismatches early, and more precisely, improving various error messages. In particular, this eliminates the case in `failed_to_match_macro` to check for a function-like invocation of a macro with no function-like rules. Instead, macro kind mismatches now result in an unresolved macro, and we detect this case in `unresolved_macro_suggestions`, which now carefully distinguishes between a kind mismatch and other errors. This also handles cases of forward-referenced attributes and cyclic attributes. ---- In this PR, I've minimally fixed up `rustdoc` so that it compiles and passes tests. This is just the minimal necessary fixes to handle the switch to `MacroKinds`, and it only works for macros that don't actually have multiple kinds. This will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros. I'd appreciate some help from a rustdoc expert on that. ---- r? ````````@petrochenkov````````
2025-08-12rustdoc: Minimal fixes to compile with `MacroKinds`Josh Triplett-21/+46
This makes the minimal fixes necessary for rustdoc to compile and pass existing tests with the switch to `MacroKinds`. It only works for macros that don't actually have multiple kinds, and will panic (with a `todo!`) if it encounters a macro with multiple kinds. rustdoc needs further fixes to handle macros with multiple kinds, and to handle attributes and derive macros that aren't proc macros.
2025-08-11Propagate TraitImplHeader to hirCameron Steffen-3/+6
2025-08-08Reduce indirect assoc parent queriesCameron Steffen-1/+1
2025-08-05rustdoc: fix caching of intra-doc links on reexportsbinarycat-1/+19
2025-08-05updated doc commentKivooeo-4/+4
2025-08-02Rollup merge of #144766 - Berrysoft:patch-1, r=GuillaumeGomezSamuel Tardieu-0/+1
Add human readable name "Cygwin" Closes rust-lang/rust#144680
2025-08-02Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdocSamuel Tardieu-3/+3
[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers. Use Rust 2024 edition representation for unsafe attributes in rustdoc HTML: - `#[no_mangle]` -> `#[unsafe(no_mangle)]` - `#[export_name = "foo"]` -> `#[unsafe(export_name = "foo")]` - `#[link_section = ".text"]` -> `#[unsafe(link_section = ".text")]` The 2024 edition representation is used regardless of the crate's own edition. This ensures that Rustaceans don't have to learn the rules of an outdated edition (e.g. that `unsafe()` wasn't always necessary) in order to understand a crate's documentation. After some looking through the `T-rustdoc` issues, I was not able to find an existing issue for this. Apologies if I missed it. r? ``````@aDotInTheVoid``````
2025-08-01Auto merge of #144446 - nnethercote:opt-region-constraints, r=lcnrbors-18/+22
Optimize region constraints r? `@lcnr`
2025-08-01Add human readable name "Cygwin"Yuyi Wang-0/+1
2025-07-31Rollup merge of #144726 - jdonszelmann:move-attr-data-structures, r=lcnrJana Dönszelmann-8/+6
merge rustc_attr_data_structures into rustc_hir this move was discussed on zulip: [#t-compiler > attribute parsing rework @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20parsing.20rework/near/528530091) Many PRs in the attribute rework depend on this move.
2025-07-31Rollup merge of #144712 - nnethercote:dedup-num-types, r=fmeaseJana Dönszelmann-37/+0
Deduplicate `IntTy`/`UintTy`/`FloatTy`. There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. r? `@fmease`
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-8/+6
2025-07-31Overhaul `Constraint`.Nicholas Nethercote-18/+22
This commit changes it to store a `Region` instead of a `RegionVid` for the `Var` cases: - We avoid having to call `Region::new_var` to re-create `Region`s from `RegionVid`s in a few places, avoiding the interning process, giving a small perf win. (At the cost of the type allowing some invalid combinations of values.) - All the cases now store two `Region`s, so the commit also separates the `ConstraintKind` (a new type) from the `sub` and `sup` arguments in `Constraint`.
2025-07-31Deduplicate `IntTy`/`UintTy`/`FloatTy`.Nicholas Nethercote-37/+0
There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. The one annoying wrinkle is that the old version had differences in their `Debug` impls, e.g. one printed `u32` while the other printed `U32`. Some compiler error messages rely on the former (yuk), and some clippy output depends on the latter. So the commit also changes clippy to not rely on `Debug` and just implement what it needs itself.
2025-07-31Remove `TyCtxt::get_attrs_unchecked`.Nicholas Nethercote-6/+3
It's identical to `TyCtxt::get_all_attrs` except it takes `DefId` instead of `impl Into<DefIf>`.
2025-07-26Fix toolingJonathan Brouwer-31/+20
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-23[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.Predrag Gruevski-3/+3
2025-07-19Fix clippy lints in librustdocGuillaume Gomez-6/+4
2025-07-17parse `const trait Trait`Deadbeef-2/+2
2025-07-17Auto merge of #144044 - fmease:rollup-kg413pt, r=fmeasebors-8/+3
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-8/+3
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-15rustdoc-json: Structured attributesAlona Enraght-Moony-55/+25
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).