Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc cannot inline associated data type #124596

Closed
StackOverflowExcept1on opened this issue May 1, 2024 · 2 comments
Closed

rustdoc cannot inline associated data type #124596

StackOverflowExcept1on opened this issue May 1, 2024 · 2 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@StackOverflowExcept1on
Copy link
Contributor

I tried this code:

// `cargo +stable doc`
pub struct Buffer<const N: usize>([u8; N]);

impl<'a, const N: usize> TryFrom<&'a [u8]> for Buffer<N> {
    type Error = <[u8; N] as TryFrom<&'a [u8]>>::Error;

    fn try_from(slice: &'a [u8]) -> Result<Self, Self::Error> {
        <[u8; N]>::try_from(slice).map(Self)
    }
}

I expected to see this happen: rustdoc can resolve type Error as std::array::TryFromSliceError

Instead, this happened: rustdoc can't inline type (i.e. it shows type Error = <[u8; N] as TryFrom<&'a [u8]>>::Error)

Meta

rustc --version --verbose:

rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6
@StackOverflowExcept1on StackOverflowExcept1on added the C-bug Category: This is a bug. label May 1, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 1, 2024
@fmease fmease added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-discussion Category: Discussion or questions that doesn't represent real issues. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. C-bug Category: This is a bug. labels May 2, 2024
@fmease
Copy link
Member

fmease commented May 2, 2024

rustdoc does support it albeit behind a nightly-only unstable CLI option only.

If you document your crate with RUSTDOCFLAGS='-Znormalize-docs' cargo +nightly doc (sh),
<[u8; N] as TryFrom<&'a [u8]>>::Error does get normalized to TryFromSliceError.

I think the plan was to normalize types by default but that lead to a whole slew of regressions — build errors — like #79459, necessitating a revert.

I haven't looked for a tracking issue for -Znormalize-docs yet but if there is one, your issue is a duplicate of it.

@fmease
Copy link
Member

fmease commented May 2, 2024

Closing as dupe of #82692.

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants