summary refs log tree commit diff
path: root/src/librustdoc/json
AgeCommit message (Collapse)AuthorLines
2024-09-29rustdoc-json: `Id(String)` -> `Id(u32)`schvv31n-308/+305
2024-09-24Dogfood `feature(file_buffered)`Josh Stone-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-23/+17
2024-09-09Auto merge of #129789 - notriddle:notriddle/inline-stmt-local, r=GuillaumeGomezbors-6/+6
rustdoc: use strategic boxing to shrink `clean::Item` * `inline_stmt_id` is never a cross-crate DefId, so save space by not storing it. * Instead of two inner boxes for `Item`, use one.
2024-09-07rustdoc: use a single box to store Attributes and ItemKindMichael Howell-6/+6
2024-09-01rustdoc: normalise type/field names in rustdoc-json-types/jsondoclintschvv31n-54/+52
2024-08-30Remove `#[macro_use] extern crate tracing` from rustdoc.Nicholas Nethercote-0/+1
2024-08-17rustdoc-json: Clean up serialization and printing.Alona Enraght-Moony-19/+23
2024-08-15rustdoc-json: Use FxHashMap from rustdoc_json_typesAlona Enraght-Moony-5/+5
2024-08-12Add possibility to generate rustdoc JSON output to stdoutGuillaume Gomez-16/+31
2024-08-05Rollup merge of #128385 - its-the-shrimp:fix_114039, r=aDotInTheVoidMatthias Krüger-6/+0
rustdoc-json: discard non-local inherent impls for primitives Fixes #114039 at least it should r? `@aDotInTheVoid`
2024-08-05rustdoc-json: discard non-local inherent implsschvv31n-6/+0
2024-08-04rustdoc: Create `SelfTy` to replace `Generic(kw::SelfUpper)`Noah Lev-1/+3
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-08-01rustdoc: Remove OpaqueTyAlona Enraght-Moony-9/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-7/+4
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-5/+15
2024-07-12Add rustdoc-json support for use<>Michael Goulet-0/+1
2024-07-03rustdoc-json: Better representation of lifetime bounds in where clauses.Alona Enraght-Moony-2/+9
As suggested [on zulip][1], there's no need to use `GenericBound` here, as the only bound a lifetime can have is that it outlives other lifetimes. While we're making breaking changes here, I also renamed it from using "region" to "lifetime", as this is more user-aligned. See [this comment][2] for details. [1]: https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/.60ItemEnum.3A.3AOpaqueTy.60/near/448871430 [2]: https://github.com/rust-lang/rust/issues/100961#issuecomment-2206565556
2024-06-28implement new effects desugaringDeadbeef-9/+7
2024-06-20Implement `unsafe_extern_blocks` feature in rustdocGuillaume Gomez-2/+4
2024-06-05Remove `Type` from rustdoc `Const`Boxy-3/+6
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-11/+11
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-11/+11
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-1/+4
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-17Rename Unsafe to SafetySantiago Pastorino-5/+5
2024-04-08Actually create ranged int types in the type system.Oli Scherer-3/+4
2024-04-08Thread pattern types through the HIROli Scherer-0/+3
2024-02-15rustdoc: cross-crate re-exports: correctly render late-bound params in ↵León Orell Valerian Liehr-14/+11
source order even if early-bound params are present
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-0/+3
2023-12-23Add `is_object_safe` information for traits in JSON outputGuillaume Gomez-0/+2
2023-11-15Re-format code with new rustfmtMark Rousskov-10/+11
2023-10-30Descriptive variant name deprecation versions outside the standard libraryDavid Tolnay-1/+1
2023-10-30Represent absence of 'since' attribute as a variant of DeprecatedSinceDavid Tolnay-4/+4
2023-10-30Add a DeprecatedSince::Err variant for versions that fail to parseDavid Tolnay-1/+8
2023-10-29Store version of `deprecated` attribute in structured formDavid Tolnay-2/+1
2023-10-22rustdoc: wrap Type with Box instead of GenericsMichael Howell-3/+3
When these `Box<Generics>` types were introduced, `Generics` was made with `Vec` and much larger. Now that it's made with `ThinVec`, `Type` is bigger and should be boxed instead.
2023-10-14Rollup merge of #115439 - fmease:rustdoc-priv-repr-transparent-heuristic, ↵Matthias Krüger-1/+2
r=GuillaumeGomez rustdoc: hide `#[repr(transparent)]` if it isn't part of the public ABI Fixes #90435. This hides `#[repr(transparent)]` when the non-1-ZST field the struct is "transparent" over is private. CC `@RalfJung` Tentatively nominating it for the release notes, feel free to remove the nomination. `@rustbot` label needs-fcp relnotes A-rustdoc-ui
2023-10-12Hide host effect params from docsOli Scherer-7/+9
2023-10-09Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmeasebors-1/+1
[rustdoc] Show enum discrimant if it is a C-like variant Fixes https://github.com/rust-lang/rust/issues/101337. We currently display values for associated constant items in traits: ![image](https://github.com/rust-lang/rust/assets/3050060/03e566ec-c670-47b4-8ca2-b982baa7a0f4) And we also display constant values like [here](file:///home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/doc/std/f32/consts/constant.E.html). I think that for coherency, we should display values of C-like enum variants. With this change, it looks like this: ![image](https://github.com/rust-lang/rust/assets/3050060/b53fbbe0-bdb1-4289-8537-f2dd4988e9ac) As for the display of the constant value itself, I used what we already have to keep coherency. We display the C-like variants value in the following scenario: 1. It is a C-like variant with a value set => all the time 2. It is a C-like variant without a value set: All other variants are C-like variants and at least one them has its value set. Here is the result in code: ```rust // Ax and Bx value will be displayed. enum A { Ax = 12, Bx, } // Ax and Bx value will not be displayed enum B { Ax, Bx, } // Bx value will not be displayed enum C { Ax(u32), Bx, } // Bx value will not be displayed, Cx value will be displayed. #[repr(u32)] enum D { Ax(u32), Bx, Cx = 12, } ``` r? `@notriddle`
2023-10-03rustdoc: fix & clean up handling of cross-crate higher-ranked lifetimesLeón Orell Valerian Liehr-3/+2
2023-09-25Show enum variant value if it is a C-like variantGuillaume Gomez-1/+1
2023-09-18rustdoc: hide repr(transparent) if it isn't part of the public ABILeón Orell Valerian Liehr-1/+2
2023-09-07Auto merge of #114855 - Urgau:rustdoc-typedef-inner-variants, r=GuillaumeGomezbors-1/+1
rustdoc: show inner enum and struct in type definition for concrete type This PR implements the [Display enum variants for generic enum in type def page](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Display.20enum.20variants.20for.20generic.20enum.20in.20type.20def.20page) #rustdoc/zulip proposal. This proposal comes from looking at [`TyKind`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/sty/type.TyKind.html) typedef from the compiler. On that page, the documentation is able to show the layout for each variant, but not the variants themselves. This proposal suggests showing the fields and variants for those "concrete type". This would mean that instead of having many unresolved generics, like in `IrTyKind`: ```rust Array(I::Ty, I::Const), Slice(I::Ty), RawPtr(I::TypeAndMut), Ref(I::Region, I::Ty, I::Mutability), FnDef(I::DefId, I::GenericArgsRef), ``` those would be resolved with direct links to the proper types in the `TyKind` typedef page: ```rust Array(Ty<'tcx>, Const<'tcx>), Slice(Ty<'tcx>), RawPtr(TypeAndMut<'tcx>), Ref(Region<'tcx>, Ty<'tcx>, Mutability<'tcx>), FnDef(DefId<'tcx>, GenericArgsRef<'tcx>), ``` Saving both time and confusion. ----- <details> <summary>Old description</summary> I've chosen to add the enums and structs under the "Show Aliased Type" details, as well as showing the variants and fields under the usual "Variants" and "Fields" sections. ~~*under new the `Inner Variants` and `Inner Fields` sections (except for their names, they are identical to the one found in the enum, struct and union pages). Those sections are complementary and do not replace anything else.*~~ This PR proposes the following condition for showing the aliased type (basically, has the aliased type some generics that are all of them resolved): - the typedef does NOT have any generics (modulo lifetimes) - AND the aliased type has some generics </details> ### Examples ```rust pub enum IrTyKind<'a, I: Interner> { /// Doc comment for AdtKind AdtKind(&'a I::Adt), /// and another one for TyKind TyKind(I::Adt, I::Ty), // no comment StructKind { a: I::Adt, }, } pub type TyKind<'a> = IrTyKind<'a, TyCtxt>; ``` ![TyKind](https://github.com/rust-lang/rust/assets/3616612/13307679-6d48-40d6-ad50-6db0b7f36ac7) <details> <summary>Old</summary> ![image](https://github.com/rust-lang/rust/assets/3616612/4147c049-d056-42d4-8a01-d43ebe747308) ![TyKind](https://user-images.githubusercontent.com/3616612/260988247-34831aa9-470d-4286-ad9f-3e8002153a92.png) ![TyKind](https://github.com/rust-lang/rust/assets/3616612/62381bb3-fa0f-4b05-926d-77759cf9115a) </details> ```rust pub struct One<T> { pub val: T, #[doc(hidden)] pub inner_tag: u64, __hidden: T, } /// `One` with `u64` as payload pub type OneU64 = One<u64>; ``` ![OneU64](https://github.com/rust-lang/rust/assets/3616612/d551b474-ce88-4f8c-bc94-5c88aba51424) <details> <summary>Old</summary> ![image](https://github.com/rust-lang/rust/assets/3616612/1a3f53c0-17bf-4aa7-894d-3fedc15b33da) ![OneU64](https://github.com/rust-lang/rust/assets/3616612/7b124a5b-e287-4efb-b9ca-fdcd1cdeeba8) ![OneU64](https://github.com/rust-lang/rust/assets/3616612/ddd962be-4f76-4ecd-81bd-531f3dd23832) </details> r? `@GuillaumeGomez`
2023-09-01Reuse const rendering from rustdoc in rmeta encodingBen Kimock-2/+2
2023-08-26rustdoc: show inner enum and struct in type definition for concrete typeUrgau-1/+1
2023-08-21rustdoc-json: Rename typedef to type aliasNoah Lev-7/+7
2023-08-21rustdoc: Rename `clean` items from typedef to type aliasNoah Lev-5/+5
2023-08-16Improve code readability by moving fmt args directly into the stringGuillaume Gomez-3/+3
2023-07-28Render generic const items in rustdocLeón Orell Valerian Liehr-2/+7
2023-05-30rustdoc: simplify `clean` by removing `FnRetTy`Michael Howell-4/+1
The default fn ret ty is always unit. Just use that. Looking back at the time when `FnRetTy` (then called `FunctionRetTy`) was first added to rustdoc, it seems to originally be there because `-> !` was a special form: the never type didn't exist back then. https://github.com/rust-lang/rust/commit/eb01b17b06eb35542bb80ff7456043b0ed5572ba#diff-384affc1b4190940f114f3fcebbf969e7e18657a71ef9001da6b223a036687d9L921-L924