| Age | Commit message (Collapse) | Author | Lines |
|
|
|
|
|
Fixes #128676
|
|
visibility
|
|
|
|
It was barely used, and the places that used it are actually clearer
without it since they were often undoing some of its work. This also
avoids an unnecessary clone of the receiver type and removes a layer of
logical indirection in the code.
|
|
This is much more readable and idiomatic, and also may help performance
since `match`es usually use switches while `if`s may not.
I also fixed an incorrect comment.
|
|
We already have special-cased code to handle inlining `Self` as the type
or trait it refers to, and this was just causing glitches like the
search `A -> B` yielding blanket `Into` impls.
|
|
Rustdoc often has to special-case `Self` because it is, well, a special
type of generic parameter (although it also behaves as an alias in
concrete impls). Instead of spreading this special-casing throughout the
code base, create a new variant of the `clean::Type` enum that is for
`Self` types.
This is a refactoring that has almost no impact on rustdoc's behavior,
except that `&Self`, `(Self,)`, `&[Self]`, and other similar occurrences
of `Self` no longer link to the wrapping type (reference primitive,
tuple primitive, etc.) as regular generics do. I felt this made more
sense since users would expect `Self` to link to the containing trait or
aliased type (though those are usually expanded), not the primitive that
is wrapping it. For an example of the change, see the docs for
`std::alloc::Allocator::by_ref`.
|
|
`SelfTy` makes it sound like it is literally the `Self` type, whereas in
fact it may be `&Self` or other types. Plus, I want to use the name
`SelfTy` for a new variant of `clean::Type`. Having both causes
resolution conflicts or at least confusion.
|
|
rustdoc: make the hover trail for doc anchors a bit bigger
https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Weird.20markdown.20heading.20rendering.3F
r? ```@GuillaumeGomez```
### Screenshots (the purple part is the padding, which the mouse can pass through to hover over it)
| Before | After |
|--|--|
|  | 
|
|
https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Weird.20markdown.20heading.20rendering.3F
|
|
Simplify `body` usage in rustdoc
No changes, just a little less code.
r? `@notriddle`
|
|
|
|
|
|
|
|
[rustdoc] Make the buttons remain when code example is clicked
Follow-up of https://github.com/rust-lang/rust/pull/125779.
One current issue we have with "run" button and the newly added copy code button is that if you're on mobile devices, you can't use them. I took a look at how `mdbook` is handling it and when you click on a code example, they show the buttons. I think it's a really good idea as if you want to copy the code on your mobile device, you will click on it, showing the buttons.
Feature can be tested [here](https://rustdoc.crud.net/imperio/click-code-example/foo/struct.Bar.html).
r? `@notriddle`
|
|
|
|
|
|
|
|
This also improves sidebar layout, so instead of
BTreeM
ap
you get this
BTree
Map
|
|
|
|
This is an alternative to ee6459d6521cf6a4c2e08b6e13ce3c6ce5d55ed0.
That is, it fixes the issue that affects the very long type names
in https://docs.rs/async-stripe/0.31.0/stripe/index.html#structs.
This is, necessarily, a pile of nasty heuristics.
We need to balance a few issues:
- Sometimes, there's no real word break.
For example, `BTreeMap` should be `BTree<wbr>Map`,
not `B<wbr>Tree<wbr>Map`.
- Sometimes, there's a legit word break,
but the name is tiny and the HTML overhead isn't worth it.
For example, if we're typesetting `TyCtx`,
writing `Ty<wbr>Ctx` would have an HTML overhead of 50%.
Line breaking inside it makes no sense.
|
|
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
|
|
[rustdoc] Add copy code feature
This PR adds a "copy code" to code blocks. Since this is a JS only feature, the HTML is generated with JS when the user hovers the code block to prevent generating DOM unless needed.
Two things to note:
1. I voluntarily kept the current behaviour of the run button (only when hovering a code block with a mouse) so it doesn't do anything on mobile. I plan to send a follow-up where the buttons would "expandable" or something. Still need to think which approach would be the best.
2. I used a picture and not text like the run button to remain consistent with the "copy path" button. I'd also prefer for the run button to use a picture (like what is used in mdbook) but again, that's something to be discussed later on.
The rendering looks like this:


It can be tested [here](https://guillaume-gomez.fr/rustdoc/bar/struct.Bar.html) (without the run button) and [here](https://guillaume-gomez.fr/rustdoc/foo/struct.Bar.html) (with the run button).
Fixes #86851.
r? ``@notriddle``
|
|
|
|
|
|
the current title is too similar to that of the page for
std::result::Result, which is a problem both for
navigating to the Result docs via browser autocomplete, and for
being able to tell which tab is which when the width of tabs is
small.
|
|
Based on e3fdafc263a4a705a3bec1a6865a4d011b2ec7c5 with a few
minor changes:
- The name sorting function is changed to follow the [version sort]
from the style guide
- the `cmp` function is redesigned to more obviously make a
partial order, by always return `cmp()` of the same variable as
the `!=` above
[version sort]: https://doc.rust-lang.org/nightly/style-guide/index.html#sorting
Co-authored-by: Guillaume Gomez <guillaume1.gomez@gmail.com>
|
|
|
|
It really wasn't necessary for the bug fix,
and could reasonably be considered a functional regression.
|
|
rustdoc: short descriptions cause word-breaks in tables
The `.item-table` class is used to display name+description lists, e.g. the exported functions, as a table. If the names are long and the descriptions are short, then the width of the table does not expand to the whole size, but only uses a fraction. This causes a some names to break inside a word.
This change makes the table always use 100% of its parent width. The `.width-limiter` wrapper already ensures that the used width still does not become excessive.
See e.g. <https://docs.rs/mathlab/0.3.0/mathlab/fun/vec_num/index.html> or <https://docs.rs/cw-events/0.0.9/cw_events/> (random choices out of the list of the recent releases).
[](https://imgur.com/XnH4eeT) [](https://imgur.com/7iQ9xE2)
The problem occurs (at least) in Firefox 130, Falkon 24, and Konqueror 22. It does not occur in Chrome 126.
|
|
Fix stab display in doc blocks
Went across this bug randomly:

With the fixed CSS:

r? ```@notriddle```
|
|
The `.item-table` class is used to display name+description lists, e.g.
the exported functions, as a table. If the names are long and the
descriptions are short, then the width of the table does not expand to
the whole size, but only uses a fraction. This causes a some names to
break inside a word.
This change makes the table always use 100% of its parent width. The
`.width-limiter` wrapper already ensures that the used width still does
not become excessive.
Signed-off-by: René Kijewski <rene.kijewski@fu-berlin.de>
|
|
|
|
Fix trait bounds display
Fixes https://github.com/rust-lang/rust/issues/127398.
I took a simple rule: if there are more than two bounds, we display them like rustfmt.
Before this PR:

After this PR:

r? `@notriddle`
|
|
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
|
|
|
|
Rollup of 7 pull requests
Successful merges:
- #112328 (Feat. adding ext that returns change_time)
- #126199 (Add `isqrt` to `NonZero<uN>`)
- #127856 (interpret: add sanity check in dyn upcast to double-check what codegen does)
- #127934 (Improve error when a compiler/library build fails in `checktools.sh`)
- #127960 (Cleanup dll/exe filename calculations in `run_make_support`)
- #127963 (Fix display of logo "border")
- #127967 (Disable run-make/split-debuginfo test for RISC-V 64)
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Fix display of logo "border"
Before:

After:

r? `@notriddle`
|
|
|
|
rustdoc: fix `current` class on sidebar modnav
| Before | After |
| -- | -- |
|  | 
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rustdoc: click target for sidebar items flush left
This change adjusts the clickable area of sidebar links to touch the leftmost edge of the canvas, making them [much easier](https://www.nngroup.com/articles/fitts-law/) to click (when the browser window is maximized or tiled left, but those cases are common enough to matter).
[Screencast from 2024-07-15 15-31-07.webm](https://github.com/user-attachments/assets/1e952d3a-e9e7-476b-b211-44a17c190b38)
<details><summary>old screencast</summary>
[Screencast from 2024-07-01 17-23-34.webm](https://github.com/rust-lang/rust/assets/1593513/dc6f9c2e-5904-403d-b353-d233e6e1afbc)
</details>
|
|
|