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: Incorrect html escaping when struct implements trait with generic type as target #46724

Closed
yoursvivek opened this issue Dec 14, 2017 · 0 comments
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@yoursvivek
Copy link

For following sample crate named docfail html doc for sidebar doesn't escape angled brackets (<, >) for generic type as target.

// src/lib.rs
use std::ops::{Deref, DerefMut};
 
/// Title
#[derive(Debug, Clone)]
pub struct Title {
    name: String,
}
 
/// Title Collection
#[derive(Debug, Clone)]
pub struct TitleList {
    pub members: Vec<Title>,
}
 
impl TitleList {
    // Constructor
    pub fn new() -> Self {
        TitleList { members: Vec::new() }
    }
}
 
impl Deref for TitleList {
    type Target = Vec<Title>;
 
    fn deref(&self) -> &Self::Target {
        &self.members
    }
}
 
impl DerefMut for TitleList {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.members
    }
}

Following is rustdoc generates html compared with expected html (diff -u target/doc/docfail/struct.TitleList.html target/doc/docfail/expected_struct.TitleList.html). Notice changes in 32nd line 200th column.

--- target/doc/docfail/struct.TitleList.html	2017-12-14 13:01:13.000000000 +0530
+++ target/doc/docfail/expected_struct.TitleList.html	2017-12-14 12:28:43.000000000 +0530
@@ -29,7 +29,7 @@
 
     <nav class="sidebar">
         
-        <p class='location'>Struct TitleList</p><div class="block items"><ul><li><a href="#fields">Fields</a></li><li><a href="#methods">Methods</a></li><li><a href="#deref-methods">Methods from Deref&lt;Target=Vec<Title>&gt;</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='index.html'>docfail</a></p><script>window.sidebarCurrent = {name: 'TitleList', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
+        <p class='location'>Struct TitleList</p><div class="block items"><ul><li><a href="#fields">Fields</a></li><li><a href="#methods">Methods</a></li><li><a href="#deref-methods">Methods from Deref&lt;Target=Vec&lt;Title&gt;&gt;</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='index.html'>docfail</a></p><script>window.sidebarCurrent = {name: 'TitleList', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
     </nav>
 
     <nav class="sub">

In my case, as the generic struct is coincidently named Title the corresponding html (<Title>) throws browser bonkers and nothing but sidebar is visible.

Rustdoc version used: rustdoc 1.22.1 (05e2e1c41 2017-11-22)

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Dec 18, 2017
@GuillaumeGomez GuillaumeGomez self-assigned this Dec 18, 2017
kennytm added a commit to kennytm/rust that referenced this issue Dec 21, 2017
… r=QuietMisdreavus

Escape more items in the sidebar when needed

Fixes rust-lang#46724.

r? @QuietMisdreavus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools 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

2 participants