Skip to content

rustdoc generates HTML with "div" embedded in an h4 #60403

Closed
@kentfredric

Description

@kentfredric

See also: #17529

Generating documentation for a struct with #[derive(Clone)] results in a page with an entry for clone_from with the following HTML:

<h4 id='method.clone_from' class="method">
<code id='clone_from.v'>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">
&amp;</a>Self)</code>
<div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div>
<a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/clone.rs.html#131-133' title='goto source code'>[src]</a>
</h4>

As per remarks on aforementioned bug, the question "Have you confirmed that this doesn't break anything? Would you be able to host a rustdoc build to demonstrate?", the way this breaks for me is far worse than failing a validator test score:

I'm attempting to run the generated HTML though html-tidy, and upon seeing the <h4><div>...</div></h4> structure, warns:

line 9 column 3 - Warning: <div> isn't allowed in <h4> elements
line 9 column 67 - Warning: discarding unexpected </div>

It then appears to "Fix" this by rewriting it as:

<h4>...</h4><div>...</div><h4>...</h4>

And the resulting page is broken beyond usable.

N.B: htmltidy also complains about duplicate anchor names, as per #25001,

line 9 column 3 - Warning: <h4> anchor "method.clone_from" already defined

But that's a seperate issue, and I'd rather have a working HTML tidier so git diff produces something useful between iterations, and then I can more properly see what is going on there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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