Use the correct file/line for doctests on both inner and outer attributes#79770
Use the correct file/line for doctests on both inner and outer attributes#79770Swatinem wants to merge 1 commit intorust-lang:masterfrom
Conversation
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 has picked a reviewer for you, use r? to override) |
|
(I added the word 'issue' between 'fix' and the issue number in the PR description so the issue won't be closed.) |
|
@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? |
|
@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 I’m not sure how widely this is used (mixing outer- and inner- doctests), but it is a bug nonetheless. |
|
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 :) |
When adding two separate doc comments to a
mod, one item-level docfor the
modstatement, 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.