Skip to content

Cargo check does not check doctests #6424

Open
@jonhoo

Description

@jonhoo

Problem
The command cargo check --all-targets does not compile doctests.

Steps

  1. Add a doctest to a project with a syntax error in it.
  2. Run cargo check --all-targets, which should "Check all targets" according to --help
  3. Observe that the error in the doctest is not reported.

Notes
I suspect this has been known for some time (#4592 (comment)). Combined with #5242, this means that there is no way to check the code in a doctest without running it (and using cargo test). From memory, I think that's because doctests are very different from all other code and tests, but I think it's surprising enough (I keep re-discovering this even now!) that it should probably be fixed.

Output of cargo version: cargo 1.32.0-nightly (b3d0b2e54 2018-11-15)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: rustdoc --testC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-checkS-needs-team-inputStatus: Needs input from team on whether/how to proceed.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions