Skip to content

Rustdoc doesn't allow to navigate to lines after 50000 #60948

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
Riateche opened this issue May 18, 2019 · 3 comments · Fixed by #61008
Closed

Rustdoc doesn't allow to navigate to lines after 50000 #60948

Riateche opened this issue May 18, 2019 · 3 comments · Fixed by #61008
Assignees
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Riateche
Copy link

When I click on the [src] link of a function in the rendered documentation, if the function's line number is greater than 50000, the browser navigates to line 50000 instead of the proper location. I found the relevant code here:

to = Math.min(50000, parseInt(match[2] || match[1], 10));

What's the rationale behind this limitation? Can it be lifted?

@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 18, 2019
@Torrencem
Copy link

Torrencem commented May 19, 2019

Interestingly, it looks like if this limit were removed, the for loop here might be a problem. Then, maybe, someone could link to a url such as https://doc.rust-lang.org/src/.../something.rs.html#1-9007199254740992 which would make the page freeze up, since the loop won't exit early if the line doesn't exist. I don't know if this would be considered harmful, however.

The edit would simply be to change the line to to = parseInt(match[2] || match[1], 10);, obviously

@Riateche
Copy link
Author

The freeze in that for loop can be avoided with something like this:

for (i = from; i <= to; ++i) {
    let element = document.getElementById(i);
    if (!element) { break; }
    addClass(element, "line-highlighted");
}

@GuillaumeGomez
Copy link
Member

Wo, super strange old code as it seems. Good catch!

@GuillaumeGomez GuillaumeGomez self-assigned this May 21, 2019
bors added a commit that referenced this issue Jun 3, 2019
…r=Manishearth

Fix lines highlighting in rustdoc source view

Fixes #60948.

This PR fixes how we handle the lines highlighting from the URL (so in "/doc/src/alloc/string.rs.html#285-283", the "285-283" part). We got a hard limit on 50000, for some unknown and lost reasons which was used in case only one line is selected.

r? @Manishearth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants