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 links point to function headers instead of the whole function starting from Rust 1.51 #100264

Open
pravic opened this issue Aug 8, 2022 · 5 comments
Labels
C-bug Category: This is a bug. P-low Low priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@pravic
Copy link
Contributor

pravic commented Aug 8, 2022

Original, before 1.51: https://doc.rust-lang.org/1.50.0/std/primitive.array.html#method.map points to https://doc.rust-lang.org/1.50.0/src/core/array/mod.rs.html#428-464

Regression, starting from 1.51: https://doc.rust-lang.org/1.51.0/std/primitive.array.html#method.map points to https://doc.rust-lang.org/1.51.0/src/core/array/mod.rs.html#429-431

I expected to see this happen: line numbers should cover the whole function

Instead, this happened: line numbers cover only the header of a function.

However, it's not stable. Sometimes, it points to the header only:

Sometimes, to the first line of the header:

Sometimes, to the whole function:

https://github.com/rust-lang/rust/blob/master/RELEASES.md#rustdoc-4

Version it worked on

It most recently worked on: 1.50

Version with regression

rustc --version --verbose:

rustc 1.62.0 (a8314ef7d 2022-06-27)
binary: rustc
commit-hash: a8314ef7d0ec7b75c336af2c9857bfaf43002bfc
commit-date: 2022-06-27
host: x86_64-unknown-linux-gnu
release: 1.62.0
LLVM version: 14.0.5
@pravic pravic added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Aug 8, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 8, 2022
@pravic
Copy link
Contributor Author

pravic commented Aug 8, 2022

@rustbot modify labels: +T-rustdoc

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 8, 2022
@camelid camelid added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-untriaged Untriaged performance or correctness regression. labels Aug 8, 2022
@camelid camelid modified the milestones: 1.50.0, 1.51.0 Aug 8, 2022
@compiler-errors
Copy link
Member

I expected to see this happen: line numbers should cover the whole function

@pravic do you rely on this behavior? This is probably related to #93967 or similar work. I would prefer if we adjusted all item spans (i.e. those "Sometimes, to the whole function:") to point to just their headers. Thoughts?

@pravic
Copy link
Contributor Author

pravic commented Aug 9, 2022

@compiler-errors To answer that question we need to establish the intention of the source highlighting. Most documentation generators for other languages point to the first line of a function (a-la https://doc.rust-lang.org/src/core/slice/mod.rs.html#3442). In Rust we have quite got used to a higher level of documentation, including the source code span highlighting (a-la https://doc.rust-lang.org/src/core/slice/mod.rs.html#3442-3469).

The in-between behavior I find quite useless and confusing: https://doc.rust-lang.org/1.51.0/src/core/array/mod.rs.html#429-431.

So, I think it's better to either revert the original behavior (highlight the whole body), or to just point to the first line. The former would be ideal.

@compiler-errors
Copy link
Member

The in-between behavior I find quite useless and confusing

I'm not sure if I completely understand why this is confusing -- presumably you're clicking the link to the function's sources so you can investigate the the body of the function, which is right below. It's not like the lines that aren't highlighted are hidden.

Pointing to just the first line seems just as arbitrary of a decision as this current behavior.

In Rust we have quite got used to a higher level of documentation, including the source code span highlighting

I'm also not sure why this is a question of documentation quality. The choice of what lines to highlight doesn't obscure the fact that the sources are there and accessible, which I think really is the quality part of this documentation anyways. 🤷

@pravic
Copy link
Contributor Author

pravic commented Aug 9, 2022

I'm not sure if I completely understand why this is confusing

Because the mind remembers that it used to highlight the whole body. Now we see only partial highlighting and we are, like, "where's the rest of the function? ah, it's below the highlighting". Basically, it's a breaking change in UX.

Pointing to just the first line seems just as arbitrary of a decision as this current behavior.

Well, it's less confusing because it doesn't highlight - it just points to the function.

@workingjubilee workingjubilee added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 3, 2023
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. P-low Low priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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

5 participants