about summary refs log tree commit diff
path: root/src/test/rustdoc
AgeCommit message (Collapse)AuthorLines
2022-04-03Rollup merge of #95613 - GuillaumeGomez:fix-rustdoc-attr-display, r=notriddleDylan DPC-0/+7
Fix rustdoc attribute display Fixes #81482. r? `@notriddle`
2022-04-03Add test for attribute display in rustdocGuillaume Gomez-0/+7
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-3/+3
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01Auto merge of #95552 - matthiaskrgr:rollup-bxminn9, r=matthiaskrgrbors-0/+22
Rollup of 6 pull requests Successful merges: - #95032 (Clean up, categorize and sort unstable features in std.) - #95260 (Better suggestions for `Fn`-family trait selection errors) - #95293 (suggest wrapping single-expr blocks in square brackets) - #95344 (Make `impl Debug for rustdoc::clean::Item` easier to read) - #95388 (interpret: make isize::MAX the limit for dynamic value sizes) - #95530 (rustdoc: do not show primitives and keywords as private) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-01Rollup merge of #95475 - ↵Matthias Krüger-4/+24
Jules-Bertholet:rustdoc-hide-assoc-consts-from-trait-impls, r=jsha rustdoc: Only show associated consts from inherent impls in sidebar Resolves #95459
2022-03-31Adjust feature names that disagree on const stabilization versionDavid Tolnay-3/+3
2022-03-31rustdoc: do not show primitives and keywords as privateMichael Howell-0/+22
2022-03-30Only show associated consts from inherent impls in sidebarJules Bertholet-4/+24
2022-03-30fix rustdoc wrt builtin impls switchlcnr-12/+11
2022-03-30update rustdoclcnr-2/+1
2022-03-30update ui testslcnr-0/+1
2022-03-29Auto merge of #95096 - GuillaumeGomez:rm-header-fn-field, r=camelidbors-0/+12
Remove header field from clean::Function Fixes https://github.com/rust-lang/rust/issues/89673. This is another take on https://github.com/rust-lang/rust/issues/89673 (compared to https://github.com/rust-lang/rust/pull/91217) but very different on the approach: I moved the header call in one place but still require to have the `clean::Item` so I can use the `DefId` to get what is missing. cc `@jyn514` (you reviewed the original so maybe you want to take a look?) r? `@camelid`
2022-03-29Add test to ensure foreign functions from dependencies are correctly handledGuillaume Gomez-0/+12
2022-03-28Auto merge of #95024 - koehlma:rustdoc-private-items, ↵bors-0/+31
r=GuillaumeGomez,camelid,jsha rustdoc: add 🔒 to items with restricted visibility This change marks items with restricted visibility with 🔒 when building with `--document-private-items`: <img width="278" alt="Screen Shot 2022-03-20 at 23 50 24" src="https://user-images.githubusercontent.com/509209/159189513-9e4b09bb-6785-41a5-bfe2-df02f83f8641.png"> There also appears a “Restricted Visibility” tooltip when hovering over the emoji. --- The original PR for reference: This change makes private items slightly transparent (similar to `unstable` items in rustc): <img width="272" alt="Screen Shot 2022-03-16 at 22 17 43" src="https://user-images.githubusercontent.com/509209/158692627-a1f6f5ec-e043-4aa2-9352-8d2b15c31c08.png"> I found myself using `--document-private-items` a lot recently because I find the documentation of private internals quite helpful when working on a larger project. However, not being able to distinguish private from public items (see #87785) when looking at the documentation makes this somewhat cumbersome. This PR addresses the third suggestion of issue #87785 by marking private items typographically. It seems to me that the other suggestions are more involved but this is at least a first step. A private item is also made slightly transparent in the path displayed in the header of a page: <img width="467" alt="Screen Shot 2022-03-16 at 22 19 51" src="https://user-images.githubusercontent.com/509209/158692885-0bbd3417-3c0b-486f-b8ab-99c05c6fa7ca.png"> I am looking forward to feedback and suggestions.
2022-03-21add tests for 🔒Maximilian Köhl-0/+31
2022-03-18Add test to ensure auto-traits are respecting constraintsGuillaume Gomez-0/+8
2022-03-10Rollup merge of #94740 - GuillaumeGomez:unify-impl-blocks, r=notriddleMatthias Krüger-1/+3
Unify impl blocks by wrapping them into a div The blanket and "auto traits" sections are wrapped into a `div` with an ID. This PR fixes this incoherence by wrapping each impl section (the "deref impl" and the "inherent impl" sections were missing it). It'll also make some tests simpler to write. r? `````@notriddle`````
2022-03-08Update GUI tests for impl blocks path changesGuillaume Gomez-0/+2
2022-03-08Unify inherent impl blocks by wrapping them into a divGuillaume Gomez-1/+1
2022-03-06Fix rustdoc for GATs with with anonymous bound regionsMichael Goulet-0/+13
2022-03-06Rollup merge of #93412 - fee1-dead:improve-rustdoc-const-bounds, ↵Matthias Krüger-1/+61
r=GuillaumeGomez Improve rustdoc const bounds - Rustdoc no longer displays `~const` in trait bounds, because it currently means nothing for stable users, and because we still haven't decided on the final syntax yet. - Rustdoc will hide trait bounds where the trait is `Drop` AND it is `~const`, i.e. `~const Drop` bounds because it has no effect on stable users as well. - Because of additional logic that hides the whole `where` statement where it consists of `~const Drop` bounds (so it doesn't display `struct Foo<T>() where ;` like that), bounds that have no trait e.g. `where [T; N+1]: ;` are also hidden. Cherry-picked from #92433.
2022-03-06Auto merge of #93805 - petrochenkov:doclinkself, r=camelid,GuillaumeGomezbors-0/+8
rustdoc: Stop textually replacing `Self` in doc links before resolving them Resolve it directly to a type / def-id instead. Also never pass `Self` to `Resolver`, it is useless because it's guaranteed that no resolution will be found. This is a pre-requisite for https://github.com/rust-lang/rust/issues/83761.
2022-03-04Auto merge of #94009 - compiler-errors:gat-rustdoc, r=GuillaumeGomezbors-0/+34
Support GATs in Rustdoc Implements: 1. Rendering GATs in trait definitions and impl blocks 2. Rendering GATs in types (e.g. in the return type of a function) Fixes #92341 This is my first rustdoc PR, so I have absolutely no idea how to produce tests for this. Advice from the rustdoc team would be wonderful! I tested locally and things looked correct: ![image](https://user-images.githubusercontent.com/3674314/153988325-9732cbf3-0645-4e1a-9e64-ddfd93877b55.png)
2022-03-03add testsMichael Goulet-0/+34
2022-03-03Rollup merge of #94550 - GuillaumeGomez:HKF-macros, r=notriddleMatthias Krüger-0/+21
rustdoc: Add test for higher kinded functions generated by macros Fixes #75564. The problem has been solved apparently so adding a test to prevent a regression. r? ```@notriddle```
2022-03-03Add test for higher kinded functions generated by macrosGuillaume Gomez-0/+21
2022-03-03Rollup merge of #94101 - notriddle:notriddle/strip-test-cases, r=GuillaumeGomezMatthias Krüger-0/+9
rustdoc: add test cases for hidden enum variants
2022-02-27Rollup merge of #94417 - GuillaumeGomez:fix-duplicated-impl-links, r=notriddleMatthias Krüger-0/+20
Fix duplicated impl links Fixes #78701. The problem is that the blanket impl has the same ID as the other impl, except that we don't derive IDs when we generate the sidebar. We now do. r? ``@notriddle``
2022-02-27Add test to ensure that links to impls are correctly generatedGuillaume Gomez-0/+20
2022-02-22Add test for infinite redirectionGuillaume Gomez-0/+29
2022-02-22Add ui testDeadbeef-0/+60
2022-02-22Bless rustdoc testDeadbeef-1/+1
2022-02-20Rollup merge of #94091 - GuillaumeGomez:rustdoc-const-computed-value, r=oli-obkMatthias Krüger-0/+9
Fix rustdoc const computed value Fixes #85088. It looks like this now (instead of hexadecimal): ![Screenshot from 2022-02-17 17-55-39](https://user-images.githubusercontent.com/3050060/154532115-0f9861a0-406f-4c9c-957f-32bedd8aca7d.png) r? ````@oli-obk````
2022-02-19Add rustdoc test for const computed valueGuillaume Gomez-0/+9
2022-02-18rustdoc: Collect traits in scope for lang itemsVadim Petrochenkov-0/+40
2022-02-17rustdoc: add test cases for hidden enum variantsMichael Howell-0/+9
2022-02-16Update rustdoc tests to adapt to changes to the sidebarGuillaume Gomez-33/+33
2022-02-13rustdoc: Consider enum variants when resolving assoc items in doc linksVadim Petrochenkov-0/+8
2022-02-10Rollup merge of #93830 - camelid:cleanup-section-code, r=GuillaumeGomezMatthias Krüger-1/+1
Refactor sidebar printing code This is the refactoring parts of #92660, plus the trait aliases capitalization consistency fix. I think this will be necessary for #92658. r? `@GuillaumeGomez`
2022-02-09Title-case trait aliases section for consistencyNoah Lev-1/+1
2022-02-08Rollup merge of #93715 - GuillaumeGomez:horizontal-trim, r=notriddleMatthias Krüger-1/+1
Fix horizontal trim for block doc comments Fixes #93662. r? `@notriddle`
2022-02-07Update rustdoc testGuillaume Gomez-1/+1
2022-02-05Auto merge of #93539 - petrochenkov:doclink, r=camelid,michaelwoeristerbors-0/+19
rustdoc: Collect traits in scope for foreign inherent impls Inherent impls can be inlined for variety of reasons (impls of reexported types, impls available through `Deref`, impls inlined for unclear reasons like in https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480). If an impl is inlined, then doc links in its comments are resolved and we may need the set of traits that are in scope at that impl's definition point. So in this PR we simply collect traits in scope for *all* inherent impls from other crates if their `Self` type is public, which is very similar for the strategy for trait impls previously used in https://github.com/rust-lang/rust/pull/88679. Fixes https://github.com/rust-lang/rust/issues/93476 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1026520300 Fixes https://github.com/rust-lang/rust/pull/88679#issuecomment-1023929480
2022-02-04Rollup merge of #93576 - jsha:fix-rustdoc-html, r=GuillaumeGomezMatthias Krüger-98/+99
Emit more valid HTML from rustdoc Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute. We can suppress those warnings with flags to tidy, and get a run that returns 0 (success): ``` tidy -o /dev/null -quiet --drop-empty-elements no --warn-proprietary-attributes no build/x86_64-unknown-linux-gnu/doc/std/string/trait.ToString.html ``` Note: this requires the latest version of tidy-html5, built from https://github.com/htacg/tidy-html5. Older versions (including the default version on Ubuntu 21.10) think `<section>` can't occur inside `<summary>`. Demo: https://rustdoc.crud.net/jsha/fix-rustdoc-html/std/string/struct.String.html r? `@GuillaumeGomez`
2022-02-04rustdoc: Collect traits in scope for foreign inherent implsVadim Petrochenkov-0/+19
2022-02-02Rollup merge of #93542 - GuillaumeGomez:lifetime-elision, r=oli-obkMatthias Krüger-0/+5
Prevent lifetime elision in type alias Fixes #93401. Apparently, the problem has been fixed in the compiler. r? `@oli-obk`
2022-02-02Emit valid HTML from rustdocJacob Hoffman-Andrews-98/+99
Previously, tidy-html5 (`tidy`) would complain about a few things in our HTML. The main thing is that `<summary>` tags can't contain `<div>`s. That's easily fixed by changing out the `<div>`s for `<span>`s with `display: block`. However, there's also a rule that `<span>`s can't contain heading elements. `<span>` permits only "phrasing content" https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span, and `<h3>` (and friends) are "Flow content, heading content, palpable content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements We have a wrapping `<div>` that goes around each `<h3>`/`<h4>`, etc. We turn that into a `<section>` rather than a `<span>` because `<section>` permits "flow content". https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section After this change we get only three warnings from tidy, run on struct.String.html: line 6 column 10790 - Warning: trimming empty <span> line 1 column 1118 - Warning: <link> proprietary attribute "disabled" line 1 column 1193 - Warning: <link> proprietary attribute "disabled" The empty `<span>` is a known issue - there's a span in front of the search box to work around a strange Safari issue. The `<link>` attributes are the non-default stylesheets. We can probably refactor theme application to avoid using this proprietary "disabled" attribute.
2022-02-01Add test to ensure lifetime is not elided in type aliasGuillaume Gomez-0/+5
2022-01-30Rollup merge of #92908 - dtolnay:rustdoc, r=GuillaumeGomezEric Huss-7/+53
Render more readable macro matcher tokens in rustdoc Follow-up to #92334. This PR lifts some of the token rendering logic from https://github.com/dtolnay/prettyplease into rustdoc so that even the matchers for which a source code snippet is not available (because they are macro-generated, or any other reason) follow some baseline good assumptions about where the tokens in the macro matcher are appropriate to space. The below screenshots show an example of the difference using one of the gnarliest macros I could find. Some things to notice: - In the **before**, notice how a couple places break in between `$(....)`↵`*`, which is just about the worst possible place that it could break. - In the **before**, the lines that wrapped are weirdly indented by 1 space of indentation relative to column 0. In the **after**, we use the typical way of block indenting in Rust syntax which is put the open/close delimiters on their own line and indent their contents by 4 spaces relative to the previous line (so 8 spaces relative to column 0, because the matcher itself is indented by 4 relative to the `macro_rules` header). - In the **after**, macro_rules metavariables like `$tokens:tt` are kept together, which is how just about everybody writing Rust today writes them. ## Before ![Screenshot from 2022-01-14 13-05-53](https://user-images.githubusercontent.com/1940490/149585105-1f182b78-751f-421f-a234-9dbc04fa3bbd.png) ## After ![Screenshot from 2022-01-14 13-06-04](https://user-images.githubusercontent.com/1940490/149585118-d4b52ea7-3e67-4b6e-a12b-31dfb8172f86.png) r? `@camelid`
2022-01-30Rollup merge of #93441 - ↵Matthias Krüger-0/+30
notriddle:notriddle/collect-crate-doc-links-very-early, r=petrochenkov rustdoc: load the set of in-scope traits for modules with no docstring Fixes #93428 This fix is a response to a couple of special cases related to the `module_id`, which is eventually used for trait candidates: * The module id is always set to the current crate, when checking `crate::`. Normally, the set of in-scope traits would be set in `load_links_in_attrs`, but if there are no doc comments, then that loop will never run. * the module id is set to the parent module, when resolving a module that is spelled like this: // Notice how we use an outlined doc comment here! // [`Test::my_fn`] mod something { } As with the above problem with `crate::`, we need to make sure the module gets its traits in scope resolved, even if it has no doc comments of its own.