rust-lang / rust-lang/rust

rustdoc: Weird display of `<ToBytes for Simd<_, _>>::Bytes` associated type

Open
#129,165 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-generics A-cross-crate-reexports C-bug T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Implementations of ToBytes for various portable SIMD vectors are rendered incorrectly:

type Bytes = Simd<u8, core::::core_simd::to_bytes::{impl#55}::Bytes::{constant#0}>

https://doc.rust-lang.org/nightly/std/simd/prelude/struct.Simd.html#impl-ToBytes-for-Simd%3Cf32,+8%3E

(looks the same on stable: https://doc.rust-lang.org/stable/std/simd/prelude/struct.Simd.html#impl-ToBytes-for-Simd%3Cf32,+8%3E)

It’s probably reproducible with some other traits and types, but I was not able to do it. Notably, this:

pub trait Foo {
    type Bar;
}

struct Arr<T, const N: usize>(T);

macro_rules! gen_impl {
    ($a:literal, [$($b:literal),*]) => {
        $(impl Foo for [u8; $b] {
            type Bar = Arr<u8, { $a * $b }>;
        })*
    };
}

gen_impl!(2, [3, 4]);

renders as

type Bar = Arr<u8, { $a * $b }>

for me (stable + rustc 1.82.0-nightly (64ebd39da 2024-08-03)), which is maybe not perfect, but isn’t that broken.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked rustdoc pages and the ToBytes/Simd rendering example, then compare it with the supplied Foo/Arr macro case to isolate the associated-type display path. Done means the SIMD associated type renders as valid Rust without the duplicated core path or unresolved macro tokens.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.