Skip to content

Rustdoc does not substitute const parameters #82852

Open

Description

I ran cargo doc on this code (src/lib.rs):

// #![feature(min_const_generics)] // stable by now

type Array<T, const N: usize> = [T; N];

pub type A0 = [i32; 3];           // printed correctly
pub type A1 = Array<i32, 3>;      // printed INCORRECTLY as `[i32; N]` (should print `[i32; 3]`)
pub struct B0(pub [i32; 3]);      // printed correctly
pub struct B1(pub Array<i32, 3>); // printed INCORRECTLY as `B1(pub [i32; N])` (should print `[i32; 3]`)

I expected to see the definitions type A1 = [i32; 3]; and pub struct B1(pub [i32; 3]); in the generated documentation.
Instead, I found type A1 = [i32; N]; and pub struct B1(pub [i32; N]);.

That is, the definitions wrongly contain a stray identifier N that should have been substituted with the literal 3 just like the T was successfully substituted with i32.

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (51748a8fc 2021-03-05)
binary: rustc
commit-hash: 51748a8fc77283914d4135f31b5966a407208187
commit-date: 2021-03-05
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

@rustbot modify labels: +T-rustdoc +A-const-generics +F-min_const_generics +C-bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions