Skip to content

neither RUSTFLAGS nor RUSTDOCFLAGS passed to rustdoc by "cargo test --doc" #123424

@decathorpe

Description

@decathorpe

We're running cargo test for many Rust crates we package in Fedora Linux to ensure they work in our environment and on all CPU architectures that we support. We define RUSTFLAGS="--cap-lints=warn" (among other things) to avoid crates starting to fail to build due to things like #![deny(warnings)] with newer Rust versions that add new lints.

Passing "--cap-lints=warn" with RUSTFLAGS works fine for normal library code and test code, but it doesn't get applied to rustdoc when it checks / compiles doctests, and this often causes problems because many crates use #![deny(warnings)] for their doctests / example code in doc comments.

I tried defining RUSTDOCFLAGS="--cap-lints=warn" in addition to having this flag already present in RUSTFLAGS, it didn't change the behaviour. I tried adding a build.rustdocflags = "--cap-lints=warn" setting to .cargo/config, and it didn't change anything either.

It appears that cargo test --doc isn't passing either RUSTFLAGS or RUSTDOCFLAGS to rustdoc correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions