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

Use the correct file/line for doctests on both inner and outer attributes #79770

Closed
wants to merge 1 commit into from

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Dec 6, 2020

When adding two separate doc comments to a mod, one item-level doc
for the mod statement, and one file-level doc for the module file,
doctests that are defined in the module file get the wrong filename/line
assigned to them.

does not yet fix issue #79764, as I still have to figure out how all of this fits together ;-) So far, I just created a testcase for this.

When adding two separate doc comments to a `mod`, one item-level doc
for the `mod` statement, and one file-level doc for the module file,
doctests that are defined in the module file get the wrong filename/line
assigned to them.
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 6, 2020
@camelid camelid added A-doctests Area: Documentation tests, run by rustdoc T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 6, 2020
@camelid
Copy link
Member

camelid commented Dec 6, 2020

(I added the word 'issue' between 'fix' and the issue number in the PR description so the issue won't be closed.)

@jyn514
Copy link
Member

jyn514 commented Dec 6, 2020

@Swatinem I expect the fix will look something like #78611. But it seemed like a lot of complexity for not much benefit :/

#79764 is confusing me - can you explain why it should say mod_with_file_doctest.rs instead of lib.rs? It's hard for me to keep track of which code belongs to which example, it sounds like there are 5 or so examples and only one is buggy?

@Swatinem
Copy link
Contributor Author

Swatinem commented Dec 6, 2020

@jyn514 thanks for the quick reply. Yes, it seems very much like the root cause is similar to #78611, essentially when you have both outer- and inner doctests, the inner doctest takes the file/line information from the outer doc, which is then wrong.

And yes, from #79764, only one of the examples is wrong, the inner-doctest for the mod that also has an outer-doctest. The doctest points to a line number that doesn’t even exist in the file.

I’m not sure how widely this is used (mixing outer- and inner- doctests), but it is a bug nonetheless.

@jyn514
Copy link
Member

jyn514 commented Dec 6, 2020

@Swatinem sounds good to me - I'm not planning to follow up on #78611 so feel free to copy as much of that code as you need to make this work.

@jyn514 jyn514 changed the title Use the correct file/line for doctests from split mod comment Use the correct file/line for doctests on both inner and outer attributes Dec 6, 2020
@jyn514 jyn514 added the A-attributes Area: #[attributes(..)] label Dec 6, 2020
@jyn514 jyn514 assigned jyn514 and unassigned Mark-Simulacrum Dec 6, 2020
@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 7, 2021
@jyn514
Copy link
Member

jyn514 commented Jan 7, 2021

@Swatinem let me know if you need help figuring out how #78611 works.

@jyn514
Copy link
Member

jyn514 commented Feb 15, 2021

I'm going to close this for now since it hasn't seen activity in a while. Feel free to re-open if you have time to work on this :)

@jyn514 jyn514 closed this Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-doctests Area: Documentation tests, run by rustdoc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants