Commit Graph

166 Commits

Author SHA1 Message Date
Matthias Krüger
3238a97d39
Rollup merge of #113058 - GuillaumeGomez:improve-code-comments, r=notriddle
Add/improve code comments

Working on something else and did some small comments updates/adds.

r? `@notriddle`
2023-06-27 07:01:32 +02:00
Guillaume Gomez
32f056ce6b Add/improve code comments 2023-06-26 16:38:14 +02:00
Takayuki Maeda
40e3fcfd59
Rollup merge of #112920 - fmease:rustdoc-fix-112904, r=GuillaumeGomez
rustdoc: render generic params & where-clauses of cross-crate assoc tys in impls

We used to only ever render generic parameters & where-clauses of cross-crate associated types when the item was located inside of a trait and we used to just drop them when it was inside of an impl block (trait or inherent).

Fixes #112904.

`@rustbot` label A-cross-crate-reexports
2023-06-26 23:16:16 +09:00
bors
7f01f03061 Auto merge of #113038 - matthiaskrgr:rollup-sdcfkxa, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112976 (Add test for futures with HRTB)
 - #113013 (rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list)
 - #113030 (Add a regression test for #109071)
 - #113031 (Add a regression test for #110933)
 - #113036 (Accept `ReStatic` for RPITIT)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-25 22:01:21 +00:00
León Orell Valerian Liehr
247aa06f10
rustdoc: handle assoc const equalities in cross-crate impl-Trait-in-arg-pos 2023-06-25 15:42:32 +02:00
León Orell Valerian Liehr
d23c334707
rustdoc: get rid of extra line when line-wrapping fn decls with empty arg list 2023-06-24 23:39:35 +02:00
León Orell Valerian Liehr
c643bedf7c
rustdoc: render gen params & where-clauses of cross-crate assoc tys in impl blocks 2023-06-24 12:20:26 +02:00
Matthias Krüger
4821f80716
Rollup merge of #112960 - GuillaumeGomez:rustdoc-files-check, r=notriddle
[tests/rustdoc] Add @files command

The ``````@!has`````` checks is very problematic as it wouldn't catch if the file scheme is updated and the file is generated again. ``````@files`````` allows to ensure that the given folder contains exactly the provided entries (files and folders).

I'm wondering if we should forbid the ``````@!has`````` for files. To be discussed after this PR I suppose.

r? `````@notriddle`````
2023-06-23 19:40:00 +02:00
Guillaume Gomez
752fb52ae9 Add @files checks in rustdoc tests 2023-06-23 15:12:48 +02:00
Matthias Krüger
3feee9f1f2
Rollup merge of #112927 - GuillaumeGomez:where-clause-indent, r=notriddle
Fix indentation for where clause in rustdoc pages

Screenshot of the bug:

![image](https://github.com/rust-lang/rust/assets/3050060/090cfeaa-0edc-46c7-9ea0-e26ac865b2c2)

I used this opportunity to clarify the code a bit because some weird things were going on.

r? ````@notriddle````
2023-06-23 13:18:13 +02:00
Guillaume Gomez
b858a4745c Update existing snapshot and add more snapshots of where clause indentation 2023-06-22 17:39:23 +02:00
Matthias Krüger
3ba66df643
Rollup merge of #112906 - fmease:rustdoc-render-assoc-ty-body-before-where-clause, r=notriddle
rustdoc: render the body of associated types before the where-clause

Fixes #112903.
2023-06-22 06:29:33 +02:00
León Orell Valerian Liehr
b866113d19
rustdoc: render the assoc ty body before the where-clause 2023-06-21 21:53:55 +02:00
Guillaume Gomez
f5470af6a6
Rollup merge of #112894 - GuillaumeGomez:gui-fields-display, r=notriddle
Fix union fields display

![Screenshot from 2023-06-21 16-47-24](https://github.com/rust-lang/rust/assets/3050060/833b0fe6-7fb6-4371-86c3-d82fa0c3fe49)

So two bugs in this screenshot: no whitespace between field name and type name, both fields are on the same line. Both problems come from issues in the templates because all whitespace are removed if a askama "command" follows.

r? `@notriddle`
2023-06-21 20:00:51 +02:00
Guillaume Gomez
805edb0a4a Add test to prevent regression for fields display 2023-06-21 17:42:53 +02:00
Guillaume Gomez
009d72b3ae
Rollup merge of #112853 - GuillaumeGomez:type_alias_type, r=oli-obk
Add `lazy_type_alias` feature gate

Add the `type_alias_type` to be able to have the weak alias used without restrictions.

Part of #112792.

cc `@compiler-errors`
r? `@oli-obk`
2023-06-21 15:45:16 +02:00
Guillaume Gomez
53761e1222 Correctly handle Weak type aliases in rustdoc 2023-06-21 15:34:42 +02:00
Guillaume Gomez
3ad595a316 Add tests for invalid files generation 2023-06-21 15:21:32 +02:00
Guillaume Gomez
1af48beed7 Add rustdoc tests for lazy_type_alias 2023-06-21 13:45:00 +02:00
Matthias Krüger
9bc95a4bc9
Rollup merge of #112304 - GuillaumeGomez:re-exports, r=notriddle
Add chapter in rustdoc book for re-exports and add a regression test for `#[doc(hidden)]` behaviour

Fixes https://github.com/rust-lang/rust/issues/109449.
Fixes https://github.com/rust-lang/rust/issues/53417.

After the discussion in #109697, I made a few PRs to fix a few corner cases:
 * https://github.com/rust-lang/rust/pull/112178
 * https://github.com/rust-lang/rust/pull/112108
 * https://github.com/rust-lang/rust/pull/111997

With this I think I covered all cases. Only thing missing at this point was a chapter covering re-exports in the rustdoc book.

r? `@notriddle`
2023-06-15 17:52:36 +02:00
Guillaume Gomez
b93ca0146a Add regression test for #112515 2023-06-12 11:35:19 +02:00
Guillaume Gomez
87d2361dcb Revert "Add regression test for #32077"
This reverts commit 6f552c800b.
2023-06-12 11:18:28 +02:00
bors
7820972f86 Auto merge of #107637 - fmease:rustdoc-reelide-x-crate-def-tr-obj-lt-bnds, r=notriddle,cgillot,GuillaumeGomez
rustdoc: re-elide cross-crate default trait-object lifetime bounds

Hide trait-object lifetime bounds (re-exported from an external crate) if they coincide with [their default](https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes).
Partially addresses #44306. Follow-up to #103885. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/clean_middle_ty.3A.20I.20need.20to.20add.20a.20parameter/near/307143097).

Most notably, if `std` exported something from `core` containing a type like `Box<dyn Fn()>`, then it would now be rendered as `Box<dyn Fn(), Global>` instead of `Box<dyn Fn() + 'static, Global>` (hiding `+ 'static` as it is the default in this case). Showing `Global` here is a separate issue, #80379, which is on my agenda.

Note that I am not really fond of the fact that I had to add a parameter to such a widely used function (30+ call sites) to address such a niche bug.

CC `@GuillaumeGomez`
Requesting a review from a compiler contributor or team member as recommended on Zulip.
r? compiler

---

`@rustbot` label T-compiler T-rustdoc A-cross-crate-reexports
2023-06-10 18:28:14 +00:00
Guillaume Gomez
6f552c800b Add regression test for #32077 2023-06-09 10:36:22 +02:00
León Orell Valerian Liehr
3490a510d5
rustdoc: re-elide cross-crate default trait object lifetime bounds 2023-06-07 13:29:36 +02:00
Guillaume Gomez
a2ec5f8a77 Add rustdoc test to ensure that #109449 is working as expected 2023-06-05 10:48:34 +02:00
bors
51f714c8c5 Auto merge of #110945 - wackbyte:doc-vis-on-inherent-assoc-types, r=jsha
rustdoc: render visibility on associated types

This should only affect inherent associated types (#8995).
2023-06-05 04:54:21 +00:00
Matthias Krüger
0d6749c2af
Rollup merge of #112178 - GuillaumeGomez:fix-inline-private-intermediate, r=notriddle
Fix bug where private item with intermediate doc hidden re-export was not inlined

This fixes this bug:

```rust
mod private {
    /// Original.
    pub struct Bar3;
}

/// Hidden.
#[doc(hidden)]
pub use crate::private::Bar3;
/// Visible.
pub use self::Bar3 as Reexport;
```

In this case, `private::Bar3` should be inlined and renamed `Reexport` but instead we have:

```
pub use self::Bar3 as Reexport;
```

and no links.

There were actually two issues: the first one is that we forgot to check if the next intermediate re-export was doc hidden. The second was that we made the `#[doc(hidden)]` attribute inheritable, which shouldn't be possible.

r? `@notriddle`
2023-06-04 13:21:28 +02:00
Guillaume Gomez
d029800992 Update reexport-attr-merge rustdoc test 2023-06-03 19:57:17 +02:00
Guillaume Gomez
653f9c7f28 Add rustdoc test for double-hyphen to dash doc comment conversion 2023-06-02 13:51:01 +02:00
Guillaume Gomez
a825b1e5da Add regression test where private item with intermediate doc hidden re-export was not inlined 2023-06-01 18:35:00 +02:00
Dylan DPC
0baa30129b
Rollup merge of #108459 - benediktwerner:rustdoc-fix-link-match, r=GuillaumeGomez
rustdoc: Fix LinkReplacer link matching

It currently just uses the first link with the same href which might not necessarily be the matching one.

This fixes replacements when there are several links to the same item but with different text (e.g. `[X] and [struct@X]`). It also fixes replacements in summaries since those use a links list with empty hrefs, so currently all links would always match the first link by href but then not match its text. This could also lead to a panic in the `original_lext[1..len() - 1]` part when the first link only has a single character, which is why the new code uses `.get(..)` instead.
2023-06-01 11:09:42 +05:30
benediktwerner
9968f3ce55
rustdoc: Fix LinkReplacer link matching 2023-05-30 21:22:30 +02:00
Guillaume Gomez
9906504c64 Add regression test for re-export of doc hidden item inside private item not displayed 2023-05-30 20:27:53 +02:00
Guillaume Gomez
480ac69a4c
Rollup merge of #111997 - GuillaumeGomez:re-export-doc-hidden-macros, r=notriddle
Fix re-export of doc hidden macro not showing up

It's part of the follow-up of https://github.com/rust-lang/rust/pull/109697.

Re-exports of doc hidden macros should be visible. It was the only kind of re-export of doc hidden item that didn't show up.

r? `@notriddle`
2023-05-27 13:38:33 +02:00
Guillaume Gomez
898dfc680f Correctly handle multiple re-exports of bang macros at the same level 2023-05-27 00:25:37 +02:00
Guillaume Gomez
c908d1e4de Update tests for re-exports of doc hidden macros 2023-05-26 17:31:54 +02:00
Lukas Markeffsky
28ce0b9940 rustdoc: add test for strikethrough with single tildes
Also merge the two almost identical strikethrough tests together and document what the test tests.
2023-05-25 13:27:29 +00:00
Lukas Markeffsky
f4ce0458e9 rustdoc: include strikethrough in item summary 2023-05-21 18:00:11 +02:00
Guillaume Gomez
0f1d4b5d4d Add regression test for #111415 2023-05-16 14:35:46 +02:00
Michael Goulet
6509c42d16 Use proper impl self type for alias impl in rustdoc 2023-05-10 22:49:05 +00:00
Matthias Krüger
d117b41409
Rollup merge of #111095 - GuillaumeGomez:fix-assoc-item-trait-inside-hidden, r=notriddle
Correctly handle associated items of a trait inside a `#[doc(hidden)]` item

Fixes https://github.com/rust-lang/rust/issues/111064.

cc `@compiler-errors`
r? `@notriddle`
2023-05-10 06:12:14 +02:00
Guillaume Gomez
8de4308b43 Add regression test for #111064 2023-05-05 21:33:44 +02:00
León Orell Valerian Liehr
61e1eda6db
IAT: Rustdoc integration 2023-05-04 16:59:11 +02:00
León Orell Valerian Liehr
e8139dfd5a
IAT: Introduce AliasKind::Inherent 2023-05-04 16:59:10 +02:00
Matthias Krüger
5dec8dff7b
Rollup merge of #110631 - notriddle:notriddle/impl-trait-cycle, r=GuillaumeGomez
rustdoc: catch and don't blow up on impl Trait cycles

Fixes #110629

An odd feature of Rust is that `Foo` is invalid, but `Bar` is okay:

    type Foo<'a, 'b> = Box<dyn PartialEq<Foo<'a, 'b>>>;
    type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>>;

To get it right, track every time rustdoc descends into a type alias, so if it shows up twice, it can be write the path instead of infinitely expanding it.
2023-04-30 16:25:46 +02:00
Michael Howell
b1d08275a9 rustdoc: catch and don't blow up on impl Trait cycles
An odd feature of Rust is that `Foo` is invalid, but `Bar` is okay:

    type Foo<'a, 'b> = Box<dyn PartialEq<Foo<'a, 'b>>>;
    type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>>;

To get it right, track every time rustdoc descends into a type alias,
so if it shows up twice, it can be write the path instead of
infinitely expanding it.
2023-04-29 16:53:02 -07:00
Matthias Krüger
549b3a13a1
Rollup merge of #110983 - GuillaumeGomez:foreign-repr, r=notriddle
rustdoc: Get `repr` information through `AdtDef` for foreign items

As suggested by `@notriddle,` this approach works too. The only downside is that the display of the original attribute isn't kept, but I think it's an acceptable downside.

r? `@notriddle`
2023-04-30 01:14:59 +02:00
Guillaume Gomez
2693e20aa3 Extend foreign inlined item with #[repr()] test 2023-04-29 22:53:10 +02:00
wackbyte
16749d1d99
Add visibility tests for associated items 2023-04-29 16:19:57 -04:00