Repository navigation
Have an option to output warnings from doctests #41574
Description
Activity
- addedT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.and removedC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
on Apr 27, 2017 I can put it back if you want. Just waiting for @rust-lang/docs team confirmation.
This might be a tools team question, less-so a docs team one.
Let's make them join the issue then!
cc @rust-lang/tools
- changed the title
[-]doctests don't print warnings by default[/-][+]Have an option to output warnings from doctests[/+]on Apr 29, 2017 I've updated the title to better reflect what I think this request is, please correct it if I've misunderstood.
Many doc tests are small and would have warnings for unused variables, etc. I wouldn't want to see these by default, but I'd be ok with a flag to turn on just output of doc test warnings. I don't think I'd use it, but I wouldn't mind it being there.
Is there any way to get a sense of how many people would use this if it existed and the kinds of problems it would prevent, in order to prioritize this?
Reacted by Corey FarwellThe standard library handles this by denying all warnings, but it seems reasonable to have a flag. I don't think we can change the default behavior.
Reacted by Corey FarwellOk, so I think we can consider this as acceptable. I'll add the flag.
- addedB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.
on May 5, 2017 - addedT-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.Relevant to the dev-tools subteam, which will review and decide on the PR/issue.and removed
on May 18, 2017 14 remaining items
- added a commit that references this issue
on Apr 6, 2018 Triage: not aware of any movement on this front, though @BurntSushi did come up with a good use-case for this in #55632
Reacted by Andrew GallantJust realized it's been ages ago. We have a
--display-warningsoption on rustdoc (nightly only for the moment). I'll send a PR for stabilization. Closing this issue then.EDIT: actually, I think there are issues remaining. Just not sure if they should be considered as issues or not... Re-opening the issue until we have this option stabilized.
- addedA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdoc
on Aug 27, 2020 Re-opening the issue until we have this option stabilized.
The option is still unstable; the PR that closed this just renamed it.
Many doc tests are small and would have warnings for unused variables, etc. I wouldn't want to see these by default, but I'd be ok with a flag to turn on just output of doc test warnings. I don't think I'd use it, but I wouldn't mind it being there.
I just opened #91259 which
a) doesn't show any warnings by default,
b) lets you use--test-args --show-outputto show all warnings but theunusedlints, and
c) lets you add#![warn(unused)]to get all warnings without exceptions.Does that seem like a reasonable solution? Or do you think rustdoc should show all lints besides
unusedby default? That's not quite a breaking change, but I'd want to do a crater run to see how noisy it ends up being (especially since I don't think we should add a way to disable the warnings per-invocation if we do that).do you think rustdoc should show all lints besides unused by default?
I tried implementing this just now and it was a little tricky, since if rustdoc passes
--show-outputto libtest, it will show output from all tests, includingcompile_failtests. Not sure how this could work.
Running cargo test runs doctests by default, and shows warnings for regular code, but not for the doctests themselves. This can be enabled by running cargo test -- --nocapture. I'd like to have warnings also show in our CI tests, even for doctests, but setting -- --nocapture shows all the output which we don't want (and can't control, because they come from the underlying libraries complaining about our tests that are supposed to fail).
I'd think having warnings on for doctests by default would be good, but that wouldn't be backwards compatible. Maybe a --doctest-warnings option could be added in lieu of that?
I believe this was done in 5d145c1, so discussion there might be worth reading. It seems that there are a bunch of warnings that come up with doctests that should be ignored, but there are also ones that can appear that shouldn't be. The question is how do we address both needs?