about summary refs log tree commit diff
path: root/src/librustdoc/clean/inline.rs
AgeCommit message (Collapse)AuthorLines
2025-07-13Retire hir::*ItemRef.Camille GILLOT-1/+1
2025-07-08Fix weird rustdoc output when single and glob reexport conflict on a nameGuillaume Gomez-2/+8
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-1/+1
2025-06-16rustdoc: skip `MetaSized` boundsDavid Wood-2/+16
These should never be shown to users at the moment.
2025-06-10rustdoc: Refractor `clean_ty_generics`Alona Enraght-Moony-60/+9
2025-05-29Rework `#[doc(cfg(..))]` checks as distinct pass in rustdocUrgau-2/+2
2025-05-26rustdoc: use custom `CfgMatchesLintEmitter` to make check-cfg workUrgau-2/+2
2025-04-17Rollup merge of #139943 - fmease:rustdoc-ixcre-trait-aliases, r=GuillaumeGomezMatthias Krüger-21/+22
rustdoc: Support inlined cross-crate re-exported trait aliases Previously we'd just drop them. As a result of this PR, [`core::ptr::Thin`](https://doc.rust-lang.org/nightly/core/ptr/traitalias.Thin.html) will be admitted into the `std` façade! Also, render the where clause *after* the bounds / the `=`, not before them, as it should be. r? rustdoc
2025-04-17Support inlined cross-crate re-exported trait aliasesLeón Orell Valerian Liehr-21/+22
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-6/+6
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-10Rename some `name` variables as `ident`.Nicholas Nethercote-2/+2
It bugs me when variables of type `Ident` are called `name`. It leads to silly things like `name.name`. `Ident` variables should be called `ident`, and `name` should be used for variables of type `Symbol`. This commit improves things by by doing `s/name/ident/` on a bunch of `Ident` variables. Not all of them, but a decent chunk.
2025-03-27Auto merge of #138927 - nnethercote:rearrange-Item-ItemInner, r=GuillaumeGomezbors-7/+7
rustdoc: Rearrange `Item`/`ItemInner`. The `Item` struct is 48 bytes and contains a `Box<ItemInner>`; `ItemInner` is 104 bytes. This is an odd arrangement. Normally you'd have one of the following. - A single large struct, which avoids the allocation for the `Box`, but can result in lots of wasted space in unused parts of a container like `Vec<Item>`, `HashSet<Item>`, etc. - Or, something like `struct Item(Box<ItemInner>)`, which requires the `Box` allocation but gives a very small Item size, which is good for containers like `Vec<Item>`. `Item`/`ItemInner` currently gets the worst of both worlds: it always requires a `Box`, but `Item` is also pretty big and so wastes space in containers. It would make sense to push it in one direction or the other. #138916 showed that the first option is a regression for rustdoc, so this commit does the second option, which improves speed and reduces memory usage. r? `@GuillaumeGomez`
2025-03-26rustdoc: Rearrange `Item`/`ItemInner`.Nicholas Nethercote-7/+7
The `Item` struct is 48 bytes and contains a `Box<ItemInner>`; `ItemInner` is 104 bytes. This is an odd arrangement. Normally you'd have one of the following. - A single large struct, which avoids the allocation for the `Box`, but can result in lots of wasted space in unused parts of a container like `Vec<Item>`, `HashSet<Item>`, etc. - Or, something like `struct Item(Box<ItemInner>)`, which requires the `Box` allocation but gives a very small Item size, which is good for containers like `Vec<Item>`. `Item`/`ItemInner` currently gets the worst of both worlds: it always requires a `Box`, but `Item` is also pretty big and so wastes space in containers. It would make sense to push it in one direction or the other. #138916 showed that the first option is a regression for rustdoc, so this commit does the second option, which improves speed and reduces memory usage.
2025-03-25rustdoc: remove useless `Symbol::is_empty` checks.Nicholas Nethercote-11/+1
There are a number of `is_empty` checks that can never fail. This commit removes them.
2025-03-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-2/+2
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-03-06`librustdoc`: flatten nested ifsYotam Ofek-4/+6
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-1/+1
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-1/+1
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-01-13rustdoc: Eliminate `AttributesExt`Noah Lev-2/+2
The new code is more explicit and avoids trait magic that added needless complexity to this part of rustdoc.
2025-01-12rustdoc: Extract `AttributesExt::cfg` trait method as functionNoah Lev-7/+10
It's never overridden, so it shouldn't be on the trait.
2024-12-15Add hir::AttributeJonathan Dönszelmann-11/+11
2024-11-28Fix new clippy lintsGuillaume Gomez-2/+2
2024-11-13rustdoc: Treat decl macros like other itemsLeón Orell Valerian Liehr-13/+5
2024-10-26expand: Stop using artificial `ast::Item` for macros loaded from metadataVadim Petrochenkov-20/+6
2024-09-30rustdoc: rewrite stability inheritance as a passLukas Markeffsky-0/+1
2024-09-25de-rc external traitsLukas Markeffsky-3/+2
Don't keep the `external_traits` as shared mutable data between the `DocContext` and `clean::Crate`. Instead, move the data over when necessary. This allows us to get rid of a borrowck hack in the `DocVisitor`.
2024-09-24Fix toolsMichael Goulet-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+7
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-27/+24
2024-09-07rustdoc: use `LocalDefId` for inline stmtMichael Howell-11/+11
It's never a cross-crate DefId, so save space by not storing it.
2024-08-31Rollup merge of #129774 - nnethercote:rm-extern-crate-tracing-remainder, ↵Matthias Krüger-0/+1
r=GuillaumeGomez Remove `#[macro_use] extern crate tracing` from rustdoc and rustfmt A follow-up to #129767 and earlier PRs doing this for `rustc_*` crates. r? ```@GuillaumeGomez```
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-08-29Fix clippy lintsGuillaume Gomez-16/+12
2024-08-04rustdoc: Create `SelfTy` to replace `Generic(kw::SelfUpper)`Noah Lev-11/+5
Rustdoc often has to special-case `Self` because it is, well, a special type of generic parameter (although it also behaves as an alias in concrete impls). Instead of spreading this special-casing throughout the code base, create a new variant of the `clean::Type` enum that is for `Self` types. This is a refactoring that has almost no impact on rustdoc's behavior, except that `&Self`, `(Self,)`, `&[Self]`, and other similar occurrences of `Self` no longer link to the wrapping type (reference primitive, tuple primitive, etc.) as regular generics do. I felt this made more sense since users would expect `Self` to link to the containing trait or aliased type (though those are usually expanded), not the primitive that is wrapping it. For an example of the change, see the docs for `std::alloc::Allocator::by_ref`.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-27rustdoc: use strategic ThinVec/Box to shrink `clean::ItemKind`Michael Howell-9/+6
2024-06-05Remove `Type` from rustdoc `Const`Boxy-13/+15
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-3/+3
2024-05-17Rename Unsafe to SafetySantiago Pastorino-1/+1
2024-05-07rustdoc: use stability, instead of features, to decide what to showMichael Howell-28/+19
To decide if internal items should be inlined in a doc page, check if the crate is itself internal, rather than if it has the rustc_private feature flag. The standard library uses internal items, but is not itself internal and should not show internal items on its docs pages.
2024-04-04In case a foreign item has `doc(hidden)` attribute, we simply merged its ↵Guillaume Gomez-5/+14
attributes with the re-export's, making it being removed once in the `strip_hidden` pass. The solution was to use the same as for local reexported items: merge attributes, but not some of them (like `doc(hidden)`).
2024-03-14Refactor visibility_print_with_space to directly take an itemManish Goregaokar-3/+13
2024-03-12Change `DefKind::Static` to a struct variantOli Scherer-1/+1
2024-02-17Fix missing trait impls for type in rustc docsShoyu Vanilla-7/+12
2024-02-15rustdoc: cross-crate re-exports: correctly render late-bound params in ↵León Orell Valerian Liehr-14/+36
source order even if early-bound params are present
2024-02-11Auto merge of #120619 - compiler-errors:param, r=lcnrbors-18/+38
Assert that params with the same *index* have the same *name* Found this bug when trying to build libcore with the new solver, since it will canonicalize two params with the same index into *different* placeholders if those params differ by name.
2024-02-09Unify item relative path computation in one functionGuillaume Gomez-3/+16
2024-02-07Use correct param env when building and cleaning items in librustdocMichael Goulet-18/+38
2024-02-04Prevent running some code if it is already in the mapGuillaume Gomez-0/+8
2024-01-17Make crate_inherent_impls fallible and stop using `track_errors` for itOli Scherer-2/+2