Skip to content

--target $host causes doctests to be silently ignored #8392

@alecmocatta

Description

@alecmocatta

Problem

--target causes doctests to be silently ignored even though target == host.

Steps

$ cargo new --lib doctesttest
$ cd doctesttest
$ echo $'/// ```\n/// invalid\n/// ```\npub fn abc() {}' > src/lib.rs
$ cargo test
# runs doctests and fails
$ cargo test --target x86_64-apple-darwin
# doesn't run doctests and succeeds
$ cargo test --target x86_64-apple-darwin -Zdoctest-xcompile
# runs doctests and fails

One other thing I noticed: doctests for proc-macro crates do seem to run.

Possible Solution(s)

Using -Zdoctest-xcompile works as a workaround but of course is unstable.

Notes

Output of cargo version:

$ cargo -V
cargo 1.46.0-nightly (79c769c3d 2020-06-11)
$ rustc -Vv
rustc 1.46.0-nightly (f455e46ea 2020-06-20)
binary: rustc
commit-hash: f455e46eae1a227d735091091144601b467e1565
commit-date: 2020-06-20
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions