Skip to content

rustdoc generates <div> in <h4> when implementing things with #[must_use] and other attributes #60865

Closed
@kentfredric

Description

@kentfredric

Similar to #60403

For example, when one generates rustdoc for something that implements Iterator, the generated HTML is (with manual pretty-printing)

<h4 id='method.collect' class="method">
  <code id='collect.v'>
    <div class="docblock attributes">
      #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
    </div>
    fn
    <a href='https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#method.collect' 
      class='fnname'>collect</a>
      &lt;B&gt;(self) -&gt; B 
     <span class="where fmt-newline">
       where<br>&nbsp;&nbsp;&nbsp;&nbsp;B: 
       <a class="trait" 
            href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.FromIterator.html" 
            title="trait core::iter::traits::collect::FromIterator">FromIterator</a>
       &lt;Self::
       <a class="type"
            href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item" 
            title="type core::iter::traits::iterator::Iterator::Item">Item</a>
        &gt;,&nbsp;
     </span>
   </code>
   <span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span>
   <a class='srclink' 
         href='https://doc.rust-lang.org/nightly/src/core/iter/traits/iterator.rs.html#1464-1466' 
         title='goto source code'>[src]</a>
</h4>

This HTML contradicts HTML spec, and causes problems when parsed by a strict parser ( such as html-tidy )

Additionally, this renders very oddly:

snapshot_20190516_100607
snapshot_20190516_100626

rustc --version
#rustc 1.36.0-nightly (372be4f36 2019-05-14)

Metadata

Metadata

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