about summary refs log tree commit diff
path: root/src/librustdoc
AgeCommit message (Collapse)AuthorLines
2023-09-08Add missing Debuginfo to PDB debug file on windows.Florian Schmiderer-0/+10
Set Arg0 and CommandLineArgs in MCTargetoptions so LLVM outputs correct CL and CMD in LF_DEBUGINFO instead of empty/invalid values.
2023-09-07rustdoc: remove unused ID `mainThemeStyle`Michael Howell-3/+1
This was added in 003b2bc1c65251ec2fc80b78ed91c43fb35402ec and used to build the URL of the theme stylesheets. It isn't used any more, because f9e1f6ffdf03ec33cb29e20c88fc7bcc938c7f42 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
2023-09-07Auto merge of #114855 - Urgau:rustdoc-typedef-inner-variants, r=GuillaumeGomezbors-146/+462
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-06Render missing fields in tuple struct/enum as /* private fields */Michael Goulet-14/+30
2023-09-05Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obkbors-2/+2
Use relative positions inside a SourceFile. This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space. cc `@Zoxc`
2023-09-03rustdoc: fix test case for generics that look like namesMichael Howell-1/+2
2023-09-03rustdoc: bug fix for `-> option<t>`Michael Howell-1/+5
2023-09-03rustdoc-search: add support for type parametersMichael Howell-290/+472
When writing a type-driven search query in rustdoc, specifically one with more than one query element, non-existent types become generic parameters instead of auto-correcting (which is currently only done for single-element queries) or giving no result. You can also force a generic type parameter by writing `generic:T` (and can force it to not use a generic type parameter with something like `struct:T` or whatever, though if this happens it means the thing you're looking for doesn't exist and will give you no results). There is no syntax provided for specifying type constraints for generic type parameters. When you have a generic type parameter in a search query, it will only match up with generic type parameters in the actual function, not concrete types that match, not concrete types that implement a trait. It also strictly matches based on when they're the same or different, so `option<T>, option<U> -> option<U>` matches `Option::and`, but not `Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches `Option::or`, but not `Option::and`.
2023-09-03rustdoc-search: `null`, not `-1`, for missing idMichael Howell-14/+14
This allows us to use negative numbers for others purposes.
2023-09-03Rollup merge of #115490 - pitaj:rustdoc-searchjs-comment, r=GuillaumeGomezGuillaume Gomez-8/+17
rustdoc: update comment in search.js for #107629 Addressing https://github.com/rust-lang/rust/pull/107629#issuecomment-1693460106 r? `@jsha`
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-2/+2
2023-09-03Auto merge of #115436 - GuillaumeGomez:fix-type-based-search, r=notriddlebors-135/+242
[rustdoc] Fix type based search Fixes https://github.com/rust-lang/rust/issues/114522. The problem was a bit more tricky than I originally thought it would be: we only kept type ID and generics in short, but as soon as there was a full path in the user query, the element didn't get an ID anymore because the ID map didn't know about `x::y` (although it knew about `y`). So for this first problem, I instead always pass the element name to get the ID. Then a new problem occurred: we actually needed to check if paths matched, otherwise whatever the path, as long as the "end types" match, it's all good. meaning, we needed to add path information, but to do so, we needed it to be added into the search index directly as there was no mapping between `"p"` and `"q"`. I hope this explanation makes sense to someone else than me. ^^' r? `@notriddle`
2023-09-02rustdoc: update comment in search.js for #107629Peter Jaszkowiak-8/+17
2023-09-02Correctly handle paths from foreign itemsGuillaume Gomez-11/+46
2023-09-02Auto merge of #115286 - saethlin:detangler, r=petrochenkovbors-100/+8
Skip rendering metadata strings from include_str!/include_bytes! The const rendering code in rustdoc completely ignores consts from expansions, but the compiler was rendering all consts. So some consts (namely those from `include_bytes!`) were rendered then ignored. Most of the diff here is from moving `print_const_expr` from rustdoc into `rustc_hir_pretty` so that it can be used in rustdoc and when building rmeta files.
2023-09-01Auto merge of #115276 - fmease:rustdoc-obj-lt-defs-handle-self-ty-params, ↵bors-8/+23
r=GuillaumeGomez rustdoc: correctly deal with self ty params when eliding default object lifetimes Fixes #115179.
2023-09-01Reuse const rendering from rustdoc in rmeta encodingBen Kimock-100/+8
2023-09-01rustdoc: correctly deal with self ty params when eliding default object ↵León Orell Valerian Liehr-8/+23
lifetimes
2023-09-01Merge all loops into one when generating search indexGuillaume Gomez-92/+65
2023-09-01[rustdoc] Fix path in type-based searchGuillaume Gomez-36/+139
2023-08-31Improve `search.js` codeGuillaume Gomez-17/+13
2023-08-30Do not ICE in rustdoc.Camille GILLOT-1/+1
2023-08-30Use conditional synchronization for LockJohn Kåre Alsaker-3/+3
2023-08-28rustdoc: always print type alias inner type (with it's where clauses)Urgau-22/+14
2023-08-27Unify CSS color formats a bit moreGuillaume Gomez-14/+14
2023-08-26Add note about lazy_type_aliasMichael Howell-2/+2
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2023-08-26rustdoc: remove details for type alias inner type and fix sidebarUrgau-94/+94
2023-08-26rustdoc: normalize all typedef inner typesUrgau-0/+25
2023-08-26rustdoc: bind typedef inner type items to the folding systemUrgau-35/+48
This let's us handle a multitude of things for free: - #[doc(hidden)] - private fields/variants - --document-private-items - --document-hidden-items And correct in the process the determination of "has stripped items" by doing the same logic done by other ones.
2023-08-26rustdoc: handle typedef inner type when doing cross-crate inliningUrgau-10/+6
2023-08-26rustdoc: show inner enum and struct in type definition for concrete typeUrgau-5/+231
2023-08-24rustdoc: list matching impls on type aliasesMichael Howell-4/+43
Remake of "List matching impls on type aliases" * 4b1d13d9841c815915433ca2a3088a8e3e97ad96 * 6f552c800b38b3e71c5e33a295e8b490d2018c71 * 2ce7cd906bde70d8cbd9b07b31c6a7bf1131c345 Partially reverts "Fix infinite loop when retrieving impls for type alias", but keeps the test case. This version of the PR avoids the infinite loop by structurally matching types instead of using full unification. This version does not support type alias trait bounds, but the compiler does not enforce those anyway (https://github.com/rust-lang/rust/issues/21903).
2023-08-24rustdoc: extract logic for printing enum fields and struct variantsUrgau-131/+195
2023-08-24Auto merge of #115078 - camelid:tydef-to-alias, r=aDotInTheVoid,GuillaumeGomezbors-54/+58
rustdoc: Rename typedef to type alias This matches the name used by the [Rust Reference][1], which is also what people usually call these items. [1]: https://doc.rust-lang.org/reference/items/type-aliases.html r? `@GuillaumeGomez`
2023-08-23Rollup merge of #115135 - GuillaumeGomez:no-html-source-flag, r=notriddleGuillaume Gomez-1/+9
Rustdoc: Add unstable --no-html-source flag Fixes https://github.com/rust-lang/rust/issues/115060. This is the equivalent of `#![doc(no_html_source)]` but on the command-line. It disables the generation of the source pages (and of the links pointing to them as well). The motivation behind this is to enable to reduce documentation size when generating it in some locations without enforcing this to end users or adding a new feature to enable/disable the crate attribute. r? `@notriddle`
2023-08-23Add unstable `--no-html-source` rustdoc flagGuillaume Gomez-1/+9
2023-08-21rustdoc: use unicode-aware checks for redundant explicit link fastpathMichael Howell-14/+4
Fixes #115064
2023-08-21rustdoc-json: Rename typedef to type aliasNoah Lev-12/+12
2023-08-21rustdoc: Rename `clean` items from typedef to type aliasNoah Lev-48/+52
2023-08-21rustdoc: Rename "Type Definition" to "Type Alias"Noah Lev-3/+3
This matches the name used by the Rust Reference [1], which is also what people usually call these items. [1]: https://doc.rust-lang.org/reference/items/type-aliases.html
2023-08-21Auto merge of #106561 - GuillaumeGomez:warning-block, r=rustdocbors-3/+26
Add warning block support in rustdoc Fixes https://github.com/rust-lang/rust/issues/79710. You can test it [here](https://rustdoc.crud.net/imperio/warning-block/foo/struct.Foo.html). It currently looks like this: ![image](https://user-images.githubusercontent.com/3050060/211413494-e1cf04e4-c081-4a9d-97db-27329405cfa7.png) So a few things to note: * Since it's a new add and it's changing the UI, we'll need to go through an FCP. * Does the UI looks good? * Is the way picked to add a warning block ok for everyone? The discussion on the issue seemed to be in favour of this solution but it doesn't hurt to double-check. cc `@rust-lang/rustdoc`
2023-08-18Fix formatKyle Lin-1/+1
2023-08-18Fix private function importingKyle Lin-1/+1
2023-08-18Skip lint check when item is not fully publicKyle Lin-0/+19
2023-08-18relax redundancy constraintKyle Lin-6/+1
2023-08-18narrow down the lint trigger constraintKyle Lin-22/+51
2023-08-18fomar filesKyle Lin-4/+9
2023-08-18Still resolving rustdoc resolution panickingKyle Lin-71/+74
2023-08-18Support Reference & ReferenceUnknown link lintKyle Lin-61/+221
2023-08-18Refactor lint from rustc to rustdocKyle Lin-28/+192