rustdoc: array primitive auto trait impls are not always canonical
@fmease is already working on this.
Since May 10, 2024.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I looked at the "Auto Traits" section of the rustdoc page for array.
I expected to see this: impl<T, const N: usize> Unpin for [T; N] where T: Unpin (etc for other auto traits), this is the case on 1.77.0 docs and 1.75.0 docs.
Instead, this happened:
- On 1.76.0 stable docs, 1.78.0 stable docs and current beta docs:
impl<const N: usize> Unpin for [u8; N](etc) - On nightly docs and local
coredocs build:impl<T, const N: usize> Unpin for [MaybeUninit<T>; N] where T: Unpin
This might be somewhat nondeterministic? It appears to change between the three [u8; N], [MaybeUninit<T>; N] and [T; N in std since 1.66.0, while it's always [MaybeUninit<T>; N] in core since 1.66.0.
1.64.0-1.83.0 docs impls
- 1.83.0: std:
[MaybeUninit<T>; N], core:[MaybeUninit<T>; N] - 1.82.0: std:
[MaybeUninit<T>; N], core:[MaybeUninit<T>; N] - 1.81.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.80.0: std:
[u8; N], core:[MaybeUninit<T>; N] - 1.79.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.78.0: std:
[u8; N], core:[MaybeUninit<T>; N] - 1.77.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.76.0: std:
[u8; N], core:[MaybeUninit<T>; N] - 1.75.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.74.0: std & core:
[MaybeUninit<T>; N] - 1.73.0: std & core:
[MaybeUninit<T>; N] - 1.72.0: std:
[u8; N], core:[MaybeUninit<T>; N] - 1.71.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.70.0: std & core:
[MaybeUninit<T>; N] - 1.69.0: std & core:
[MaybeUninit<T>; N] - 1.68.0: std & core:
[MaybeUninit<T>; N] - 1.67.0: std:
[T; N], core:[MaybeUninit<T>; N] - 1.66.0: std & core:
[MaybeUninit<T>; N] - 1.65.0: std & core:
[T; N] - 1.64.0: std & core:
[T; N]
(found using for i in {78..64}; do echo -n "1.${i}.0: "; curl https://doc.rust-lang.org/1.${i}.0/std/primitive.array.html 2>/dev/null | grep -o 'impl-Unpin-for-[^"]*' | head -1 | python3 -c "import sys; from urllib.parse import unquote; print(unquote(sys.stdin.read()));"; done | sed 's/impl-Unpin-for-//', and .../core/...) (Versions <=1.63.0 only have an impl-Unpin anchor instead of impl-Unpin-for-<urlencoded-type> and I didn't want to do that much regex right now).
Based on these it looks like something may have changed 1.65.0 -> 1.66.0? It appears to be correct for versions between 1.47.0..=1.65.0 (AFAICT rustdoc started showing auto traits on array in 1.47.0).
Note that the specific type that is selected appears to be the same for all the auto traits on one version in one crate, and core seems to always use [MaybeUninit<T>; N] since 1.66.0.
@rustbot label +T-rustdoc A-auto-traits A-synthetic-impls
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.