Commit Graph

349 Commits

Author SHA1 Message Date
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
Matthias Krüger
1305119a3f
Rollup merge of #107897 - GuillaumeGomez:reexported-macros-docs, r=notriddle
Reexported macros docs

Part of #59368 (doesn't fix it, only improve the current situation a bit).

Macros were not correctly handled in reexports and the reexport attributes were not merged with the item either. This PR fixes both.

r? `@notriddle`
2023-02-11 17:18:44 +01:00
Dylan DPC
9af90ffa3c
Rollup merge of #107490 - notriddle:notriddle/rm-sidebar-tooltip, r=GuillaumeGomez
rustdoc: remove inconsistently-present sidebar tooltips

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-02-11 11:15:55 +05:30
Guillaume Gomez
295fd0d835 Add regression test for reexported macros docs 2023-02-10 18:37:32 +01:00
Dylan DPC
188dd72b5f
Rollup merge of #107655 - notriddle:notriddle/small-url-encode, r=GuillaumeGomez
rustdoc: use the same URL escape rules for fragments as for examples

Carries over improvements from #107284
2023-02-09 23:18:34 +05:30
Michael Howell
894c98652c 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-07 19:00:42 -07:00
Michael Howell
8307fd7901 rustdoc: use a newline instead of <br> to format code headers
Since these elements now use `white-space: pre-wrap` since
784665d4ce, it's fine to use newlines
for formatting, which is smaller and a bit less complicated.
2023-02-07 11:23:25 -07:00
Roland Strasser
71a147df1f rustdoc: trait bound formatting
rustdoc: fix item-spacer

rustdoc: use proper comment style

rustdoc: change formatting where clauses for traits

rustdoc: remove semicolon from provided methods

update provided methods formatting
2023-02-04 19:10:04 +01:00
Michael Howell
5f98a7f00e rustdoc: use the same URL escape rules for fragments as for examples 2023-02-03 17:58:26 -07:00
Michael Goulet
f7210b3bed
Rollup merge of #107615 - notriddle:notriddle/nbsp, r=GuillaumeGomez
Replace nbsp in all rustdoc code blocks

Based on #106125 by `@dtolnay` — this PR fixes the line wrapping bug.

Fixes #106098. This makes code copyable from rustdoc rendered documentation into a Rust source file.
2023-02-03 14:15:23 -08:00
Michael Howell
784665d4ce Replace nbsp in all rustdoc code blocks
Co-Authored-By: David Tolnay <dtolnay@gmail.com>
2023-02-03 08:15:44 -07:00
bors
6c991b0740 Auto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, r=notriddle,petrochenkov
Fix handling of items inside a `doc(hidden)` block

Fixes #106373.

cc `@aDotInTheVoid`
r? `@notriddle`
2023-02-02 21:14:44 +00:00
Michael Howell
f75b350467 rustdoc: stop making unstable items transparent
Fixes #93393
2023-01-31 11:27:09 -07:00
Michael Howell
3a20cbf9fc rustdoc: remove inconsistently-present sidebar tooltips
Discussed in
https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Inconsistent.20sidebar.20tooltips/near/323565625
2023-01-31 10:12:13 -07:00
Yuki Okushi
f95f835470
Rollup merge of #107479 - compiler-errors:probe-can-call-ocx, r=BoxyUwU
Use `ObligationCtxt::new_in_snapshot` in `satisfied_from_param_env`

We can evaluate nested `ConstEvaluatable` obligations in an evaluation probe, which will ICE if we use `ObligationCtxt::new`.

Fixes #107474
Fixes #106666

r? `@BoxyUwU` but feel free to reassign
cc `@JulianKnodt` who i think added this assertion code

Not sure if the rustdoc test is needed, but can't hurt. They're the same root cause, though.
2023-01-31 11:46:25 +09:00
Michael Goulet
343a359109 Use ObligationCtxt::new_in_snapshot in satisfied_from_param_env 2023-01-30 19:04:59 +00:00
Michael Howell
7080f80e8b rustdoc: remove unnecessary wrapper div.item-decl from HTML 2023-01-30 11:06:18 -07:00
Michael Howell
74e843c833 rustdoc: remove unused class has-srclink
Stopped being used in CSS with
73d0f7c7b6
2023-01-28 17:18:56 -07:00
Guillaume Gomez
4b3eef8734 Add rustdoc test to ensure that items into a doc(hidden) block are handled as expected 2023-01-27 20:33:42 +01:00
Michael Howell
7aa4a205a8 rustdoc: merge doctest tooltip with notable traits tooltip
Fixes https://discord.com/channels/442252698964721669/443150878111694848/1066420140167680000

Fixes #91100
2023-01-27 09:04:39 -07:00
Guillaume Gomez
c918efa664 Update rustdoc/redirect test 2023-01-27 14:50:34 +01:00
Guillaume Gomez
3f057dd600 Add regression test for impl blocks in const expr 2023-01-27 14:41:33 +01:00
Guillaume Gomez
1b64e16643 Add regression test for #107350 2023-01-27 12:11:01 +01:00
Yuki Okushi
17a2e1fef3
Rollup merge of #107336 - notriddle:notriddle/import-item-module-item, r=GuillaumeGomez
rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`
2023-01-27 12:57:57 +09:00
Yuki Okushi
d68b5a42e2
Rollup merge of #107284 - notriddle:notriddle/plus, r=jsha
rustdoc: use smarter encoding for playground URL

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    759235  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3194173 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8151    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69480   after.tar.gz

100*((69480-69600)/69600)=-0.17
2023-01-27 12:57:56 +09:00
Yuki Okushi
145241402d
Rollup merge of #107242 - notriddle:notriddle/title-ordering, r=GuillaumeGomez
rustdoc: make item links consistently use `title="{shortty} {path}"`

The ordering in item tables was flipped in 3030cbea95, making it inconsistent with the ordering in method signatures.

Compare these (before this PR is merged):

c8e6a9e8b6/src/librustdoc/html/render/print_item.rs (L455-L459)

c8e6a9e8b6/src/librustdoc/html/format.rs (L903-L908)
2023-01-27 12:57:55 +09:00
Michael Howell
97f8189614 rustdoc: remove mostly-unused CSS classes import/module-item 2023-01-26 12:55:19 -07:00
Michael Howell
51df99f3c2 rustdoc: use smarter encoding for playground URL
The old way would compress okay with DEFLATE, but this version makes
uncompressed docs smaller, which matters for memory usage and stuff
like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between
4.0% and 0.031%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    759235  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3194173 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8151    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69480   after.tar.gz

100*((69480-69600)/69600)=-0.17
2023-01-26 10:51:10 -07:00
Michael Howell
e65b36110f rustdoc: rearrange HTML in primitive reference links
This patch avoids hard-to-click single character links by making
the generic part of the link:

Before: <a href="#">&</a>T

After: <a href="#">&T</a>
2023-01-23 17:32:22 -07:00
Michael Howell
57ca36861d rustdoc: make item links consistently use title="{shortty} {path}"
The ordering in item tables was flipped in 3030cbea95, making it
inconsistent with the ordering in method signatures.

Compare these:

c8e6a9e8b6/src/librustdoc/html/render/print_item.rs (L455-L459)

c8e6a9e8b6/src/librustdoc/html/format.rs (L903-L908)
2023-01-23 14:31:35 -07:00
Guillaume Gomez
13239a9b8e Revert "Add regression test for impl blocks in const expr"
This reverts commit 9cce0bc583.
2023-01-19 20:27:37 +01:00
bors
aaa9bb9e7b Auto merge of #106952 - petrochenkov:docglob, r=notriddle,GuillaumeGomez
rustdoc: Fix glob import inlining

Filter away names that are not actually imported by the glob, e.g. because they are shadowed by something else.

Fixes the issue found in https://github.com/rust-lang/rust/pull/94857#issuecomment-1382912356.
2023-01-18 03:54:04 +00:00
Matthias Krüger
b90f62988d
Rollup merge of #106869 - notriddle:notriddle/item-decl-pre-rust, r=GuillaumeGomez
rustdoc: remove redundant item kind class from `.item-decl > pre`

This class originated in the very first commit of `rustdoc_ng`, and was used to add a color border around the item decl based on its kind.

4fd061c426/src/rustdoc_ng/html/static/main.css (L102-L106)

The item decl no longer has a border, and there aren't any kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this PR is updating test cases so that they use `item-decl` to find the `<pre>` tag instead of relying on the fact that the class name had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-17 05:25:22 +01:00
Vadim Petrochenkov
3b0d306b94 rustdoc: Fix glob import inlining
Filter away names that are not actually imported by the glob, e.g. because they are shadowed by something else
2023-01-17 00:55:28 +04:00
Michael Howell
3a3f70c94e rustdoc: remove redundant item kind class from .item-decl > pre
This class originated in the very first commit of `rustdoc_ng`, and was used
to add a color border around the item decl based on its kind.

4fd061c426/src/rustdoc_ng/html/static/main.css (L102-L106)

The item decl no longer has a border, and there aren't any
kind-specific styles in modern rustdoc's rendering of this UI item.

Most of this commit is updating test cases so that they use `item-decl` to
find the `<pre>` tag instead of relying on the fact that the class name
had `rust {kind}` in it while other `<pre>` tags only had class `rust`.
2023-01-14 11:34:03 -07:00
Matthias Krüger
14fbc21466
Rollup merge of #106828 - notriddle:notriddle/notable-trait-docblock, r=GuillaumeGomez
rustdoc: remove `docblock` class from notable trait popover

This commit builds on b72de9be74, which removes the `docblock` class from the All Items page, and 9457380ac9, which removes the `docblock` class from the item decl.

Fixes #92974
2023-01-14 18:45:27 +01:00
Yuki Okushi
caa1d47fba
Rollup merge of #106819 - notriddle:notriddle/rm-h1-fqn, r=GuillaumeGomez
rustdoc: remove unnecessary DOM class `h1.fqn`

It's misleading. The main heading sometimes isn't an fully qualified name at all.

It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-14 12:04:37 +09:00
Michael Howell
5314ed5627 rustdoc: remove docblock class from notable trait popover
This commit builds on b72de9be74, which removes
the `docblock` class from the All Items page, and
9457380ac9, which removes the `docblock` class
from the item decl.

Fixes #92974
2023-01-13 15:42:29 -07:00
Michael Howell
1d328de3ec rustdoc: rename CSS rustdoc-toggle -> toggle and toggle -> settings-toggle
This swaps things around so that the class that gets used more often has
the shorter name.
2023-01-13 12:38:03 -07:00
Michael Howell
39b90a5f6e rustdoc: remove unnecessary DOM class h1.fqn
It's misleading. The main heading sometimes isn't an fully qualified name at all.

It's also redundant. It's always a child of `div.main-heading`, so just use that.
2023-01-13 10:09:25 -07:00
Yuki Okushi
ea45b3ef1d
Rollup merge of #106741 - GuillaumeGomez:reexport-doc-hidden, r=notriddle
Fix reexport of `doc(hidden)` item

Part of #59368.

It doesn't fix the `doc(inline)` nor the `doc(hidden)` on macro. I'll do it in a follow-up PR.

r? `@notriddle`
2023-01-13 05:47:23 +09:00
Guillaume Gomez
675640c92a Add test for displayed re-export of doc(hidden) 2023-01-12 18:03:50 +01:00
clubby789
740f6aaf95 Fix rendering 'const' for intrinsics 2023-01-12 03:19:08 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00