rust/library/core/src
Dylan DPC 689978c176
Rollup merge of #80733 - steffahn:prettify_pin_links, r=jyn514
Improve links in inline code in `core::pin`.

## Context

So I recently opened #80720. That PR uses HTML-based `<code>foo</code>` syntax in place of `` `foo` `` for some inline code. It looks like usage of `<code>` tags in doc comments is without precedent in the standard library, but the HTML-based syntax has an important advantage:

You can write something like
```
<code>[Box]<[Option]\<T>></code>
```
which becomes: <code>[Box]<[Option]\<T>></code>, whereas with ordinary backtick syntax, you cannot create links for a substring of an inline code block.

## Problem
I recalled (from my own experience) that a way to partially work around this limitation is to do something like
```
[`Box`]`<`[`Option`]`<T>>`
```
which looks like this: [`Box`]`<`[`Option`]`<T>>` _(admitted, it looks even worse on GitHub than in `rustdoc`’s CSS)_.

[Box]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box"
[`Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html "Box"
[Option]: https://doc.rust-lang.org/std/option/enum.Option.html "Option"
[`Option`]: https://doc.rust-lang.org/std/option/enum.Option.html "Option"
[Pin]: https://doc.rust-lang.org/std/pin/struct.Pin.html "Pin"
[&mut]: https://doc.rust-lang.org/std/primitive.reference.html "mutable reference"

So I searched the standard library and found that e.g. the [std::pin](https://doc.rust-lang.org/std/pin/index.html) module documentation uses this hack/workaround quite a bit, with types like <code>[Pin]<[Box]\<T>></code> or <code>[Pin]<[&mut] T>></code>. Although the way they look like in this sentence is what I would like them to look like, not what they currently look.

### Status Quo

Here’s a screenshot of what it currently looks like:
![Screenshot_20210105_202751](https://user-images.githubusercontent.com/3986214/103692608-4a978780-4f98-11eb-9451-e13622b2e3c0.png)

With a few HTML-style code blocks, we can fix all the spacing issues in the above screenshot that are due usage of this hack/workaround of putting multiple code blocks right next to each other being used.

### after d3915c555e:
![Screenshot_20210105_202932](https://user-images.githubusercontent.com/3986214/103692688-6f8bfa80-4f98-11eb-9be5-9b370eaef644.png)

There’s still a problem of inconsistency. Especially in a sentence such as
> A [`Pin<P>`][Pin] where `P: Deref` should be considered as a "`P`-style pointer" to _[...]_

looks weird with the variable `P` having different colors (and `Deref` has a different color from before where it was a link, too). Or compare the difference of <code>[Pin]<[Box]\<T>></code> vs [`Box<T>`][Box] where one time the variable is part of the link and the other time it isn’t.

_Note: Color differences show even **more strongly** when the ayu theme is used, while they are a bit less prominent in the light theme than they are in the dark theme, which is the one used for these screenshots._

This is why I’ve added the next commit
### after ceaeb249a3
![Screenshot_20210105_203113](https://user-images.githubusercontent.com/3986214/103693496-ab738f80-4f99-11eb-942d-29dace459734.png)
pulling all the type parameters out of their links, and also the last commit with clearly visible changes
### after 87ac118ba3
![Screenshot_20210105_203252](https://user-images.githubusercontent.com/3986214/103693625-e5dd2c80-4f99-11eb-91b7-470c37934e7e.png)
where more links are added, removing e.g. the inconsistency with `Deref`’s color in e.g. `P: Deref` that I already mentioned above.

## Discussion

I am aware that this PR may very well be overkill. If for now only the first commit (plus the fix for the `Drop` link in e65385fbfa, the link titles 684edf7a70 as far as they apply, and a few of the line-break changes) are wanted, I can reduce this PR to just those changes. I personally find the rendered result with all these changes very nice though. On the other hand, all these `<code>` tags are not very nice in the source code, I’ll admit.

Perhaps alternative solutions could be preferred, such as `rustdoc` support for merging subsequent inline code blocks so that all the cases that currently use workarounds rendered as [`Box`]`<`[`Option`]`<T>>` automatically become <code>[Box]<[Option]\<T>></code> without any need for further changes. Even in this case, having a properly formatted, better looking example in the standard library docs could help motivate such a change to `rustdoc` by prodiving an example of the expected results and also the already existing alternative (i.e. using `<code>`). On the other hand, `` [`Box`]`<`[`Option`]`<T>>` `` isn’t particularly nice-looking source code either. I’m not even sure if I wouldn’t actually find the version `<code>[Box]<[Option]\<T>></code>` cleaner to read.

`@rustbot` modify labels: T-doc, T-rustdoc
2021-04-08 20:29:54 +02:00
..
alloc Fix const stability since versions. 2021-03-15 14:39:18 +00:00
array Use iter::zip in library/ 2021-03-26 09:32:29 -07:00
char Update char::escape_debug_ext to handle different escapes in strings vs. chars 2021-03-26 11:23:51 +03:00
convert FloatToInit: Replacing round_unchecked_to --> to_int_unchecked 2021-03-02 12:38:22 -08:00
fmt Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se 2021-03-27 20:37:07 +01:00
future Rename #[doc(spotlight)] to #[doc(notable_trait)] 2021-03-15 13:59:54 -07:00
hash Bump cfgs 2021-04-04 14:57:05 -04:00
iter Rollup merge of #81619 - SkiFire13:resultshunt-inplace, r=the8472 2021-04-04 19:19:59 +02:00
macros Bump cfgs 2021-04-04 14:57:05 -04:00
mem addr_of_mut: add example for creating a pointer to uninit data 2021-04-03 19:25:11 +02:00
num Add escape_default method to u8 and [u8] 2021-03-28 17:38:25 -04:00
ops Bump cfgs 2021-04-04 14:57:05 -04:00
prelude Bump cfgs 2021-04-04 14:57:05 -04:00
ptr Auto merge of #83864 - Dylan-DPC:rollup-78an86n, r=Dylan-DPC 2021-04-05 01:26:57 +00:00
slice Bump cfgs 2021-04-04 14:57:05 -04:00
str Update char::escape_debug_ext to handle different escapes in strings vs. chars 2021-03-26 11:23:51 +03:00
stream Remove Stream::next 2021-01-23 16:54:56 +01:00
sync Fix const stability since versions. 2021-03-15 14:39:18 +00:00
task stabilize the poll_map feature 2021-01-13 14:51:27 +10:00
unicode Add a check for ASCII characters in to_upper and to_lower 2021-02-26 11:39:36 -06:00
any.rs Fix use of bare trait objects everywhere 2021-03-18 02:18:58 +03:00
ascii.rs Fixed some intra-docs links in library/core 2020-09-18 07:49:29 +08:00
bool.rs Stabilise then 2020-11-22 13:45:14 +00:00
borrow.rs Fix borrow and deref 2021-03-03 11:23:29 +01:00
cell.rs Use #[inline(always)] on trivial UnsafeCell methods 2021-04-04 11:55:13 -07:00
clone.rs Fix core tests 2021-03-03 11:22:49 +01:00
cmp.rs Auto merge of #81047 - glittershark:stabilize-cmp-min-max-by, r=kodraus 2021-04-07 18:02:21 +00:00
default.rs Add diagnostic item to Default trait 2021-03-04 10:14:48 -08:00
ffi.rs Convert primitives to use intra-doc links 2021-02-25 20:31:53 -05:00
hint.rs Fixed documentation error 2021-01-03 19:54:54 +02:00
internal_macros.rs
intrinsics.rs Auto merge of #82122 - bstrie:dep4real, r=dtolnay 2021-03-17 19:39:03 +00:00
lazy.rs Capitalize safety comments 2020-09-08 22:26:44 -04:00
lib.rs Bump cfgs 2021-04-04 14:57:05 -04:00
marker.rs Always mention Box::pin when dealing with !Unpin 2021-04-06 19:55:45 -07:00
option.rs Remove Option::{unwrap_none, expect_none}. 2021-03-14 12:54:34 +01:00
panic.rs Implement new panic!() behaviour for Rust 2021. 2021-01-25 13:48:11 +01:00
panicking.rs Fix panic message of assert_failed_inner 2021-03-13 18:50:43 +08:00
pin.rs Fix overlength lines in core::pin. 2021-01-05 20:14:02 +01:00
primitive.rs
raw.rs
result.rs Add Result::into_err where the Ok variant can never happen 2021-03-23 21:24:26 +01:00
time.rs Rollup merge of #81465 - joshtriplett:duration-formatting-documentation, r=m-ou-se 2021-03-14 13:07:27 +09:00
tuple.rs
unit.rs