Skip to content

Ignored doctests are run with cargo test -- --ignored. #87586

Open
@thomcc

Description

@thomcc

If you use rust,ignore to ignore doctests which don't compile (often because you want to include example code that's entirely expository in your documentation — something that doesn't compile at all, and should merely syntax highlight as Rust), they still are attempted to compile and run when you pass --ignored to the test runner.

This is unfortunate, as this is what you use to run #[ignore]d tests, which are good (intended?) for tests that are too slow to complete in normal execution, often ones which are exhaustive. Having doctests that fail to compile be mixed in here means this use of #[ignore] is effectively broken.

The workaround I know for this is rather gross, e.g. using a const _: &str = stringify!{ /* code that doesn't compile here */ } wrapper (for example — even if using ignore wouldn't have been an alternative here since it's large enough that you'd rather ensure it compiles in practice, this is the pattern I'm referring to).

I think it's honestly a bug that this is the effect of rust,ignore, and think that instead it should be to just not emit the test.

(This is related to, but distinct from #30032)

I bugged @jyn514 about this once and he indicated he thought it might require an RFC to fix, but when I was complaining about it elsewhere recently, someone pointed out that there was no bug on file for it already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions