Skip to content

The doc contents are incorrectly made bold under certain situation #101743

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

Closed
cmpute opened this issue Sep 13, 2022 · 3 comments
Closed

The doc contents are incorrectly made bold under certain situation #101743

cmpute opened this issue Sep 13, 2022 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@cmpute
Copy link

cmpute commented Sep 13, 2022

Problem

This bug happens when an associated constant is generated from a generic const function. The brackets surrounding the generic parameters are interpreted as an HTML tag.

Steps

If the documentation is like this in the code:

impl<const A: Word> Repr<A> {
    /// The base of the representation. It's exposed as an [IBig] constant.
    pub const BASE: IBig = base_as_ibig::<A>();
}

The documentation looks like:
Snipaste_2022-09-12_20-17-34
(the text becomes a link)


If the documentation is

impl<const B: Word> Repr<B> {
    /// The base of the representation. It's exposed as an [IBig] constant.
    pub const BASE: IBig = base_as_ibig::<B>();

    /// Create a [Repr] instance representing value zero
    pub const fn zero() -> Self { todo!() }
}

The documentation looks like
Snipaste_2022-09-12_20-15-21

(it even affects the documentation of other items in the same page

Possible Solution(s)

The generic brackets should be escaped

Notes

No response

Version

cargo 1.63.0 (fd9c4297c 2022-07-01)
release: 1.63.0
commit-hash: fd9c4297ccbee36d39e9a79067edab0b614edb5a
commit-date: 2022-07-01
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:OpenSSL/1.1.1n)
os: Ubuntu 20.04 (focal) [64-bit]
@cmpute cmpute added the C-bug Category: This is a bug. label Sep 13, 2022
@ehuss ehuss transferred this issue from rust-lang/cargo Sep 13, 2022
@ehuss
Copy link
Contributor

ehuss commented Sep 13, 2022

Transferred to rust-lang/rust as that is where rustdoc issues are tracked.

@aDotInTheVoid
Copy link
Member

@cmpute I cannot reproduce, can you post the definition of Word, Repr, etc..


When I try

pub type Word = usize;
pub struct Repr<const B: usize>([i32; B]);
pub struct IBig(usize);

pub const fn base_as_ibig<const B: Word>() -> IBig {
    IBig(B)
}

impl<const B: Word> Repr<B> {
    /// The base of the representation. It's exposed as an [IBig] constant.
    pub const BASE: IBig = base_as_ibig::<B>();

    /// Create a [Repr] instance representing value zero
    pub const fn zero() -> Self { todo!() }
}

I get

image

Which looks correct.

It's also possible that I'm on a more recent version of rustdoc, and that this has been fixed, and needs a test

rustdoc 1.65.0-nightly (1120c5e01 2022-09-08)
binary: rustdoc
commit-hash: 1120c5e01df508de64fe6642f22fadeb574afd6d
commit-date: 2022-09-08
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

@cmpute
Copy link
Author

cmpute commented Sep 14, 2022

I tried to use nightly locally and get the same result as yours. Thanks!

Notice that your rendering output for BASE is

pub const BASE: IBig = _

rather than my rendering:

pub const BASE: IBig = base_as_ibig::()

This actually avoid the problem of parsing the generic parameters <B> as HTML tag, so I think it's fixed in the latest version.

@cmpute cmpute closed this as completed Sep 14, 2022
aDotInTheVoid added a commit to aDotInTheVoid/rust that referenced this issue Sep 14, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 15, 2022
Add test for rust-lang#101743

The issue was closes as we stopped rendering `const`s like this, but if we move back to doing that, make sure we don't accidently generate tags
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 15, 2022
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#100415 (Add BE8 support)
 - rust-lang#101559 (Adding "backtrace off" option for fuchsia targets)
 - rust-lang#101740 (Adding ignore-fuchsia arg to non-applicable compiler ui tests)
 - rust-lang#101778 (rustdoc: clean up DOM by removing `.dockblock-short p`)
 - rust-lang#101786 (Tidy will not check coding style in bootstrap/target)
 - rust-lang#101810 (Constify `PartialEq` for `Ordering`)
 - rust-lang#101812 (rustdoc: clean up CSS `#titles` using flexbox)
 - rust-lang#101820 (rustdoc: remove no-op rule `a { background: transparent }`)
 - rust-lang#101828 (Add test for rust-lang#101743)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants