Commit Graph

293 Commits

Author SHA1 Message Date
León Orell Valerian Liehr
6f5d8556ca
Handle inherent associated types fallout 2023-08-03 02:18:52 +02:00
Michael Goulet
4b58ae0bb8 Mark lazy_type_alias as incomplete 2023-07-29 19:47:15 +00:00
León Orell Valerian Liehr
203d400668
Add rustdoc tests for generic const items 2023-07-28 22:23:21 +02:00
bors
9339f446a5 Auto merge of #113374 - GuillaumeGomez:private-to-public-path, r=notriddle,fmease
[rustdoc] If re-export is private, get the next item until a public one is found or expose the private item directly

Fixes #81141.

If we have:

```rust
use Private as Something;

pub fn foo() -> Something {}
```

Then `Something` will be replaced by `Private`.

r? `@notriddle`
2023-07-27 15:56:50 +00:00
Guillaume Gomez
1fa0c4db4f
Rollup merge of #114059 - fmease:rustdoc-fix-x-crate-impl-sized, r=GuillaumeGomez
rustdoc: fix cross-crate `impl Sized` & `impl ?Sized`

Previously, cross-crate impl-Trait (APIT, RPIT, etc.) that only consists of a single `Sized` bound (modulo outlives-bounds) and ones that are `?Sized` were incorrectly rendered. To give you a taste (before vs. after):

```diff
- fn sized(x: impl ) -> impl
+ fn sized(x: impl Sized) -> impl Sized

- fn sized_outlives<'a>(x: impl 'a) -> impl 'a
+ fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a

- fn maybe_sized(x: &impl ) -> &impl
+ fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized

- fn debug_maybe_sized(x: &impl Debug) -> &impl ?Sized + Debug
+ fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized)
```

Moreover, we now surround impl-Trait that has multiple bounds with parentheses if they're the pointee of a reference or raw pointer type. This affects both local and cross-crate docs. The current output isn't correct (rustc would emit the error *ambiguous `+` in a type* if we fed the rendered code back to it).

---

Best reviewed commit by commit :)

`@rustbot` label A-cross-crate-reexports
2023-07-27 16:05:13 +02:00
bors
6908c73ab0 Auto merge of #114012 - GuillaumeGomez:fix-113982, r=notriddle
Fix missing attribute merge on glob foreign re-exports

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

The attributes were not merged with the import's in case of glob re-export of foreign items.

r? `@notriddle`
2023-07-26 17:35:51 +00:00
Guillaume Gomez
51eb0c3b36 Fix regression for private in public 2023-07-26 15:29:45 +02:00
León Orell Valerian Liehr
28d40f1959
rustdoc: fix cross-crate impl-Sized 2023-07-26 02:11:35 +02:00
bors
beef07fe8f Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkov
fix intra-doc links on nested `use` and `extern crate` items

This PR fixes two rustdoc ICEs that happen if there are any intra-doc links on nested `use` or `extern crate` items, for example:
```rust
/// Re-export [`fmt`] and [`io`].
pub use std::{fmt, io}; // "nested" use = use with braces

/// Re-export [`std`].
pub extern crate std;
```

Nested use items were incorrectly considered private and therefore didn't have their intra-doc links resolved. I fixed this by always resolving intra-doc links for nested `use` items that are declared `pub`.

<details>

During AST->HIR lowering, nested `use` items are desugared like this:
```rust
pub use std::{}; // "list stem"
pub use std::fmt;
pub use std::io;
```
Each of these HIR nodes has it's own effective visibility and the list stem is always considered private.
To check the effective visibility of an AST node, the AST node is mapped to a HIR node with `Resolver::local_def_id`, which returns the (private) list stem for nested use items.

</details>

For `extern crate`, there was a hack in rustdoc that stored the `DefId` of the crate itself in the cleaned item, instead of the `DefId` of the `extern crate` item. This made rustdoc look at the resolved links of the extern crate's crate root instead of the `extern crate` item. I've removed this hack and instead translate the `DefId` in the appropriate places.

As as side effect of fixing `extern crate`, i've turned
```rust
#[doc(masked)]
extern crate self as _;
```
into a no-op instead of hiding all trait impls. Proper verification for `doc(masked)` is included as a bonus.

fixes https://github.com/rust-lang/rust/issues/113896
2023-07-25 01:35:53 +00:00
Guillaume Gomez
95cea621cd Add regression test for generics reexport of private import 2023-07-24 17:07:57 +02:00
Guillaume Gomez
5859b44e97 Add test for --document-hidden-items 2023-07-24 17:07:57 +02:00
Guillaume Gomez
298cd366d5 Add test for private items 2023-07-24 17:07:57 +02:00
Guillaume Gomez
9fb6548905 Correctly handle super and :: 2023-07-24 17:07:57 +02:00
Guillaume Gomez
278d15c254 Extend issue-81141-private-reexport-in-public-api test to cover more cases 2023-07-24 17:07:56 +02:00
Guillaume Gomez
d67a31f058 Add regression test for #81141 2023-07-24 17:07:56 +02:00
Guillaume Gomez
7150e35c92 Add regression test for #113982 2023-07-24 16:32:06 +02:00
Lukas Markeffsky
bb98f3ad4d fix doc links on extern crate items 2023-07-22 12:27:25 +02:00
León Orell Valerian Liehr
5924043b86
rustdoc: handle cross-crate RPITITs correctly 2023-07-22 12:20:17 +02:00
Lukas Markeffsky
9ebd8095fa fix doc links on use items 2023-07-22 12:14:26 +02:00
Matthias Krüger
80f749dfa0
Rollup merge of #110765 - wackbyte:fix-defaultness-position, r=fmease,GuillaumeGomez
rustdoc: fix position of `default` in method rendering

With the following code:
```rs
#![feature(specialization)]

pub trait A {
    unsafe fn a();
}

impl A for () {
    default unsafe fn a() {}
}
```
rustdoc would render the `impl` of `a` as
```rs
unsafe default fn a()
```
which is inconsistent with the actual position of `default`.
This PR fixes this issue.
2023-07-20 17:19:32 +02:00
Matthias Krüger
53580da72d
Rollup merge of #113857 - GuillaumeGomez:document-hidden-items-test, r=notriddle
Add tests for `--document-hidden-items` option

Since `--document-hidden-items` was greatly fixed/improved in https://github.com/rust-lang/rust/pull/113574, thought it might be worth adding some more tests for it to prevent new regressions.

As for the first commit, it allows to go from:

```
Traceback (most recent call last):
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 706, in <module>
    check(sys.argv[1], get_commands(rust_test_path))
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 689, in check
    for c in commands:
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 274, in get_commands
    args = shlex.split(args)
  File "/usr/lib/python3.10/shlex.py", line 315, in split
    return list(lex)
  File "/usr/lib/python3.10/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/usr/lib/python3.10/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/usr/lib/python3.10/shlex.py", line 191, in read_token
    raise ValueError("No closing quotation")
ValueError: No closing quotation
```

to:

```
Traceback (most recent call last):
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 708, in <module>
    check(sys.argv[1], get_commands(rust_test_path))
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 691, in check
    for c in commands:
  File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 278, in get_commands
    raise Exception("line {}: {}".format(lineno + 1, exc)) from None
Exception: line 57: No closing quotation
```

Having the line where the error occurred is quite useful.

r? `@notriddle`
2023-07-20 07:08:43 +02:00
Guillaume Gomez
d9753d714d Add tests for --document-hidden-items option 2023-07-19 14:34:06 +02:00
Guillaume Gomez
c845a53aa2 Add regression test for #105735 2023-07-18 10:41:16 +02:00
Michael Howell
e72fba4160 rustdoc: use src consistently over source in JavaScript
Since the directory that contains source files is called `src`,
it makes sense to name the scripts that way, too.
2023-07-14 16:54:14 -07:00
Michael Howell
34bc8fbea3 rustdoc: use src consistently over source in code
The CSS uses an inconsistent mix of both. This commit switches
it to always use `src`.
2023-07-14 16:38:01 -07:00
Guillaume Gomez
6d44879eb3 Update jump to def tests 2023-07-12 16:50:43 +02:00
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
wackbyte
13f58a8ea0
Add tests for default unsafe trait methods 2023-06-24 23:14:57 -04: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
wackbyte
c40498422c
Restore channel placeholder 2023-04-29 15:36:03 -04:00
Matthias Krüger
39ed894926
Rollup merge of #110964 - notriddle:notriddle/deref-impl, r=GuillaumeGomez
rustdoc: fix weird margins between Deref impl items

## Before

![image](https://user-images.githubusercontent.com/1593513/235245977-90770591-22c1-4a27-9464-248a3729a2b7.png)

## After

![image](https://user-images.githubusercontent.com/1593513/235246009-0e83113e-42b7-4e29-981d-969f9d20af01.png)

## Description

In the old setup, if the dereffed-to item has multiple impl blocks, each one gets its own `div.impl-items` in the section, but there are no headers separating them. Since the last method in a `div.impl-items` has no bottom margin, and there are no margins between these divs, there is no margin between the last method of one impl and the first method of the following impl.

This patch fixes it by simplifying the HTML. Each Deref block gets exactly one `div.impl-items`, no matter how many impl blocks it actually has.
2023-04-29 15:51:17 +02:00
bors
f495605381 Auto merge of #110901 - GuillaumeGomez:inlined-repr-rustdoc, r=notriddle
rustdoc: Fix missing `repr` attribute in doc(inline) on foreign items

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

r? `@notriddle`
2023-04-28 20:33:33 +00:00
Michael Howell
2299ba1ca2 rustdoc: fix weird margins between Deref impl items
In the old setup, if the dereffed-to item has multiple impl blocks,
each one gets its own `div.impl-items` in the section, but there
are no headers separating them. Since the last method in a
`div.impl-items` has no bottom margin, and there are no margins
between these divs, there is no margin between the last method
of one impl and the first method of the following impl.

This patch fixes it by simplifying the HTML. Each Deref block gets
exactly one `div.impl-items`, no matter how many impl blocks it
actually has.
2023-04-28 13:16:10 -07:00
Michael Howell
10c77b1cd0 rustdoc: move deref tests into a directory 2023-04-28 12:54:26 -07:00
wackbyte
db5d3f04c6 rustdoc: render visibility on associated types
This should only affect inherent associated types.
2023-04-28 08:24:30 -04:00
Guillaume Gomez
3f082843aa Add regression test for #110698 2023-04-27 16:41:22 +02:00
bohan
9156b03287 test(doc): no fallback marco resolution 2023-04-27 16:25:05 +08:00
Matthias Krüger
1d73549982
Rollup merge of #110798 - ozkanonur:rustdoc-unused-extern-crates, r=jyn514
pass `unused_extern_crates` in `librustdoc::doctest::make_test`

blocker for https://github.com/rust-lang/rust/pull/106621
2023-04-26 18:51:42 +02:00
ozkanonur
f56b6d0b12 pass unused_extern_crates in librustdoc::doctest::make_test
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-04-25 17:20:58 +03:00
Guillaume Gomez
5c70287c51 Add regression test for #60522 2023-04-24 13:12:24 +02:00
Guillaume Gomez
6b33245c5b Add regression test for #46506 2023-04-20 17:49:13 +02:00
Matthias Krüger
770f6cd254
Rollup merge of #110533 - GuillaumeGomez:missing-blanket-impl-trait-not-public, r=notriddle
Missing blanket impl trait not public

Fixes #94183.

The problem was that we should have checked if the trait was reachable instead of only "directly public".

r? `@notriddle`
2023-04-19 17:54:43 +02:00
bors
3a5c8e91f0 Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obk
Rm const traits in libcore

See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework)

* [x] Bless ui tests
* [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19 13:03:40 +00:00
Guillaume Gomez
96f4f4e02e Add regression test for #94183 2023-04-19 11:32:50 +02:00
Matthias Krüger
d6468916c0
Rollup merge of #110450 - GuillaumeGomez:fix-nested-items-on-private-doc, r=notriddle,jyn514
rustdoc: Fix invalid handling of nested items with `--document-private-items`

Fixes #110422.

The problem is that only impl block and re-exported `macro_rules!` items are "visible" as nested items. This PR adds the missing checks to handle this correctly.

cc `@compiler-errors`
r? `@notriddle`
2023-04-18 06:44:47 +02:00
Guillaume Gomez
c456e15855 Add regression tests for #110422 2023-04-17 20:27:34 +02:00
Deadbeef
4c6ddc036b fix library and rustdoc tests 2023-04-16 11:38:52 +00:00
Matthias Krüger
35bd52e888
Rollup merge of #110279 - GuillaumeGomez:compiler-macro-derive, r=notriddle
rustdoc: Correctly handle built-in compiler proc-macros as proc-macro and not macro

Part of https://github.com/rust-lang/rust/issues/110111.

There were actually one issue split in two parts:
 * Compiler built-in proc-macro were incorrectly considered as macros and not proc-macros.
 * Re-exports of compiler built-in proc-macros were considering them as macros.

Both issues can be fixed by looking at the `MacroKind` variant instead of just relying on information extracted later on.

r? ``@fmease``
2023-04-14 07:58:41 +02:00
Guillaume Gomez
80c4323217 Add test to ensure that compiler built-in proc-macro are considered as such 2023-04-13 20:35:05 +02:00
Oli Scherer
f263f88bea Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
Rémy Rakic
dc04b085f4 Bless rustdoc test with swapped ids
The ids for the multiple `Item` associated type elements are swapped
between the first and second impl.
2023-04-05 15:59:29 +00:00
Michael Goulet
d984671246
Rollup merge of #109937 - compiler-errors:rustdoc-rpit-cant-be-documented, r=GuillaumeGomez
Don't collect return-position impl traits for documentation

#104889 modified the rustdoc ast collection step to use a HIR visitor, which more thoroughly walks the HIR tree. that means that we're going to encounter inner items (incl return-position impl traits and async fn opaque futures) that are not possible to document.

FIxes (but does not close due to being a beta regression) #109931

r? `@GuillaumeGomez`
2023-04-04 09:27:47 -07:00
Michael Goulet
72e535ea99
Rollup merge of #109919 - fmease:rustdoc-fix-issue-109488, r=notriddle
rustdoc: escape GAT args in more cases

Fixes #109488.

Previously we printed the *un*escaped form of GAT arguments not only when `f.alternate()` was true but *also* when we failed to compute the URL of the trait associated with the type projection, i.e. when `href(…)` returned an `Err(_)`.

In this PR the argument printing logic is entirely separate from the link resolution code above as it should be.
Further, we now only try to compute the URL if the HTML format was requested with `!f.alternate()`. Before, we would sometimes compute the `href` only to throw it away later.
2023-04-04 09:27:46 -07:00
Michael Goulet
72ef85d83e Don't collect return-position impl traits for documentation 2023-04-04 14:03:50 +00:00
León Orell Valerian Liehr
6567bc9a47
rustdoc: escape GAT args in more cases 2023-04-04 02:09:23 +02:00
Guillaume Gomez
3ef8d2d607 Update tests for rustc_doc_primitive 2023-03-30 22:56:52 +02:00
Yuki Okushi
2981d7781c
Rollup merge of #109509 - ehuss:overlapping-tests, r=Mark-Simulacrum
compiletest: Don't allow tests with overlapping prefix names

Some tests will delete their output directory before starting. The output directory is based on the test names. If one test is the prefix of another test, then when that test starts, it could try to delete the output directory of the other test with the longer path, or otherwise clash with it while the two tests are trying to create/delete/modify the same directory.

In practice, this manifested as a random error on macOS where two tests were trying to create/delete/create `rustdoc/primitive` and `rustdoc/primitive/no_std`, which resulted in an EINVAL (InvalidInput) error.

This renames some of the offending tests, adds `compiletest-ignore-dir` to prevent compiletest from processing some files, and adds a check to prevent this from happening in the future.

Fixes #109397
2023-03-30 21:07:00 +09:00
Matthias Krüger
02cb4da896
Rollup merge of #109726 - GuillaumeGomez:doc-hidden-crate, r=notriddle
rustdoc: Don't strip crate module

Until we decide something for https://github.com/rust-lang/rust/issues/109695, rustdoc won't crash anymore because the crate folder doesn't exist.

r? `@notriddle`
2023-03-29 21:19:51 +02:00
Guillaume Gomez
cdc4fa4589 Add regression test for #109695 2023-03-29 16:17:48 +02:00
Dylan DPC
1db9eae033
Rollup merge of #109534 - petrochenkov:noprimuse, r=GuillaumeGomez
rustdoc: Unsupport importing `doc(primitive)` and `doc(keyword)` modules

These are internal features used for a specific purpose, and modules without imports are enough for that purpose.
2023-03-29 14:07:27 +05:30
Michael Goulet
be9fd75d32 rustdoc + rustdoc-json support for non_lifetime_binders 2023-03-28 16:50:49 +00:00
Vadim Petrochenkov
52b15b4bf9 rustdoc: Unsupport importing doc(primitive) and doc(keyword) modules
These are internal features used for a specific purpose, and modules without imports are enough for that purpose.
2023-03-28 17:31:39 +04:00
Maybe Waffle
904dd2c398 Bless tidy 2023-03-27 18:58:07 +00:00
Ezra Shaw
e0ec9c0b9c
rustdoc: tweak some variants omitted
Don't display `// some variants omitted` if enum is marked
`#[non_exhaustive]`
2023-03-26 18:05:42 +13:00
Eric Huss
2da2ade0f7 Rename tests to ensure they don't have overlapping names.
Some tests will delete their output directory before starting.
The output directory is based on the test names.
If one test is the prefix of another test, then when that test
starts, it could try to delete the output directory of the other
test with the longer path.
2023-03-22 21:12:40 -07:00
Matthias Krüger
0392e2996e
Rollup merge of #108954 - notriddle:notriddle/notable-trait-generic, r=camelid
rustdoc: handle generics better when matching notable traits

This commit makes the `clean::Type::is_same` non-commutative (renaming it `is_doc_subtype_of`), so that a generic `impl` matches a concrete return, but a generic return does not match a concrete `impl`. It makes slice and vector Write for `u8` not match on every generic return value.

Fixes #100322

Fixes #55082

Preview:

* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.new
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/vec/struct.Vec.html#method.from-12
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/iter/trait.Iterator.html#method.intersperse_with
* https://notriddle.com/rustdoc-demo-html-3/notable-trait-generic/std/string/struct.String.html#method.as_bytes
2023-03-22 22:44:39 +01:00
Matthias Krüger
130923586d
Rollup merge of #109375 - clubby789:unescape-deprecated-doc, r=jsha
rustdoc: Fix improper escaping of deprecation reasons

Fix #109374

r? `@jsha`
2023-03-20 07:10:35 +01:00
Matthias Krüger
39e09ac334
Rollup merge of #109351 - GuillaumeGomez:no-footnote-in-summary, r=notriddle
rustdoc: Remove footnote references from doc summary

Since it's one line, we don't have the footnote definition so it doesn't make sense to have the reference.

Part of https://github.com/rust-lang/rust/issues/109024.

r? `@notriddle`
2023-03-20 07:10:33 +01:00
Matthias Krüger
c07679989a
Rollup merge of #109259 - GuillaumeGomez:fix-missing-private-inlining, r=notriddle
rustdoc: Fix missing private inlining

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

If the item isn't inlined, it shouldn't have been added into `view_item_stack`. The problem here was that it was not removed, preventing sub items to be inlined if they have a re-export in "upper levels".

cc `@epage`
r? `@notriddle`
2023-03-20 07:10:30 +01:00
clubby789
c74f2dc588 Fix improper escaping of deprecation reasons 2023-03-20 05:21:51 +00:00
Guillaume Gomez
5a752cd2ca Add test for footnote references in doc summary 2023-03-19 18:02:52 +01:00
Guillaume Gomez
e9f29c4016 Add regression test for #109258 2023-03-17 17:04:23 +01:00
Michael Howell
683c12cb91 rustdoc: remove std:: from primitive intra-doc link tooltips 2023-03-15 11:34:37 -07:00
Michael Howell
bfb66eb4bb
rustdoc: fix comments in test 2023-03-13 23:03:53 -07:00
Matthias Krüger
6ef07c2df1
Rollup merge of #108936 - GuillaumeGomez:rustdoc-anonymous-reexport, r=notriddle
Rustdoc: don't hide anonymous reexport

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

From https://github.com/rust-lang/rust/issues/108931, it appears that having anonymous re-exports for traits is actually used in some places, so instead of hiding them automatically, we should prevent them to be ever inlined.

r? `@notriddle`
2023-03-10 12:31:58 +01:00
Michael Howell
ee6b228b6a rustdoc: handle generics better when matching notable traits
This commit makes the `clean::Type::is_same` non-commutative, so
that a generic `impl` matches a concrete return, but a generic return
does not match a concrete `impl`. It makes slice and vector Write
for `u8` not match on every generic return value.
2023-03-09 14:18:12 -07:00
Michael Howell
c6015851f7 rustdoc: move notable trait tests into their own directory 2023-03-09 13:45:12 -07:00
Guillaume Gomez
9b788da2da Update rustdoc anonymous reexport test and add regression test for #108931 2023-03-09 18:08:22 +01:00
Matthias Krüger
506495a4b3
Rollup merge of #108870 - GuillaumeGomez:rustdoc-reexport-of-reexport-of-private, r=notriddle
Fix invalid inlining of reexport of reexport of private item

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

The problem is that a reexport is always resolving to the end type, so if the end type is private, the reexport inlines. Except that if you reexport a public reexport (which reexports the private item), then it should not be inlined again.

r? `@notriddle`
2023-03-09 12:11:54 +01:00
bors
7c306f6dcd Auto merge of #108121 - aliemjay:resolve-var-region, r=lcnr
always resolve to universal regions if possible

`RegionConstraintCollector::opportunistic_resolve_var`, which is used in canonicalization and projection logic, doesn't resolve the region var to an equal universal region. So if we have equated `'static == '1 == '2`, it doesn't resolve `'1` or `'2` to `'static`. Now it does!

Addresses review comment https://github.com/rust-lang/rust/pull/107376#discussion_r1093233687.

r? `@lcnr`
2023-03-08 12:33:21 +00:00
Guillaume Gomez
c0c93be7ce Addr regression test for #108679 2023-03-07 21:20:21 +01:00
Ali MJ Al-Nasrawy
095b5fae1c bless rustdoc tests 2023-03-05 14:41:35 +03:00
clubby789
7520155e4e rustdoc: Note in a type's layout/size if it is uninhabited 2023-03-04 12:07:29 +00:00
Michael Howell
5a9a3df312 rustdoc: avoid including <li> tags in item table short desc
Fixes a bug seen at https://docs.rs/gl_constants/0.1.1/gl_constants/index.html
2023-02-23 13:53:27 -07:00
Matthias Krüger
2011ced333
Rollup merge of #108349 - GuillaumeGomez:fix-duplicated-imports2, r=notriddle
rustdoc: Prevent duplicated imports

Fixes #108163.

Interestingly enough, the AST is providing us an import for each corresponding item, even though the `Res` links to multiple ones each time, which leaded to the same import being duplicated.

So in this PR, I decided to prevent the add of the import before the clean pass. However, I originally took a different path by instead filtering after cleaning the path. You can see it [here](https://github.com/rust-lang/rust/compare/master...GuillaumeGomez:rust:fix-duplicated-imports?expand=1). Only the second commit differs.

I think this approach is better though, but at least we can compare both if we want.

The first commit adds the check for duplicated items in the rustdoc-json output as asked in #108163.

cc `@aDotInTheVoid`
r? `@notriddle`
2023-02-23 06:18:07 +01:00
Guillaume Gomez
20dd1bd9a8 Add test to ensure there are no duplicated imports 2023-02-22 17:49:22 +01:00
Michael Howell
881280f1f8 rustdoc: update test case with intra-doc link pointing to method 2023-02-22 08:40:47 -07:00
Guillaume Gomez
8d33b780ff
Rollup merge of #108310 - GuillaumeGomez:fix-reexports-duplicated-attributes, r=notriddle
rustdoc: Fix duplicated attributes for first reexport

Fixes #108281.

r? ``@notriddle``
2023-02-22 10:35:10 +01:00
Guillaume Gomez
fec6ad6058 Add regression test for #108281 2023-02-21 16:26:06 +01:00
Matthias Krüger
52fa8fe376
Rollup merge of #108241 - GuillaumeGomez:fix-reexported-macro-handling, r=notriddle
Fix handling of reexported macro in doc hidden items

Fixes https://github.com/rust-lang/rust/issues/108231.
Fixes #59368.

r? `@notriddle`
2023-02-20 22:12:17 +01:00
Guillaume Gomez
fc6a05c463 Add test for reexported hidden macro 2023-02-20 20:19:21 +01:00
Guillaume Gomez
e2d9dee9eb Add regression test for #108231 2023-02-20 20:19:21 +01:00
Guillaume Gomez
bd63edc07a
Rollup merge of #108129 - GuillaumeGomez:correctly-handle-links-starting-with-whitespace, r=petrochenkov
Correctly handle links starting with whitespace

Part of https://github.com/rust-lang/rust/issues/107995.

I just got this issue, wrote a fix and then saw the issue. So here's the PR. ^^'

r? `@petrochenkov`
2023-02-19 14:47:55 +01:00
Dylan DPC
4165de40f8
Rollup merge of #107783 - notriddle:notriddle/item-table-ul, r=GuillaumeGomez
rustdoc: simplify DOM for `.item-table`

This switches from using `<div>` to the more semantic `<ul>`, and using class names that rhyme with the classes the search results table uses.
2023-02-19 13:03:41 +05:30
Guillaume Gomez
8d801fd398 Add regression test for #107995 2023-02-18 23:24:58 +01:00
Matthias Krüger
04128982ff
Rollup merge of #108057 - GuillaumeGomez:fix-reexport-attr-merge, r=notriddle
Prevent some attributes from being merged with others on reexports

Final fix for https://github.com/rust-lang/rust/issues/59368.

As discussed on zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Filtering.20sub.20attributes.20in.20ast.3A.3AAttribute), we need to clone the `Attribute` to be able to filter some parts of it. Then we need to go through the attributes to able to only keep what we want (everything except a few attributes in short).

As for the second commit, when I wrote the test, I realized that the code to traverse all reexports one by one to collect all their attributes was not completely working so I fixed the few issues remaining.

r? `@notriddle`
2023-02-16 17:51:24 +01:00
Guillaume Gomez
374f798ad2 Correctly handle reexports of #[doc(hidden)] is reexport does not use #[doc(inline)] 2023-02-15 00:00:51 +01:00
Guillaume Gomez
1ec1d94812 Add test for reexports attr merge 2023-02-14 23:23:59 +01:00
Michael Howell
ba4b026e80 rustdoc: add more tooltips to intra-doc links
This commit makes intra-doc link tooltips consistent with generated
links in function signatures and item tables, with the format
`itemtype foo::bar::baz`. This way, you can tell if a link points at
a trait or a type (for example) by mousing over it.

See also fce944d4e7
2023-02-13 22:57:28 -07:00
Matthias Krüger
3054759fa8
Rollup merge of #107340 - notriddle:notriddle/simplify-doctest-tooltip, r=GuillaumeGomez
rustdoc: merge doctest tooltip with notable traits tooltip

Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000

<details><summary>a user report where the tooltip arrow overlaps the text</summary>

![](https://cdn.discordapp.com/attachments/443150878111694848/1066420139530145812/this-example-is-not-tested-busted-rendering.png)

</details>

Fixes #91100

Preview: <https://notriddle.com/notriddle-rustdoc-demos/simplify-doctest-tooltip/std/vec/struct.Vec.html#indexing>

Screenshot:

![image](https://user-images.githubusercontent.com/1593513/214975516-72667632-4609-49fa-8c37-e8d2ba1ba7dc.png)
2023-02-13 11:34:56 +01:00
Matthias Krüger
9b503325b4
Rollup merge of #107934 - notriddle:notriddle/intra-doc-link-meta-description, r=camelid,GuillaumeGomez
rustdoc: account for intra-doc links in `<meta name="description">`

Similar to #86451, but for the SEO descriptions instead of the search descriptions.
2023-02-12 22:29:48 +01:00
Michael Howell
72b3f46b43 rustdoc: account for intra-doc links in <meta name="description"> 2023-02-11 16:10:28 -07:00