Skip to content

Commit

Permalink
Document how to address unexpected_cfgs
Browse files Browse the repository at this point in the history
Closes #370
  • Loading branch information
taiki-e committed Jul 18, 2024
1 parent 985d6f9 commit 746086b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ cfgs are set under the following conditions:
- `cfg(coverage)` is always set when using cargo-llvm-cov (unless `--no-cfg-coverage` flag passed)
- `cfg(coverage_nightly)` is set when using cargo-llvm-cov with nightly toolchain (unless `--no-cfg-coverage-nightly` flag passed)

Rust 1.80+ warns the above cfgs as `unexpected_cfgs`. The recommended way to address this is to add a [`lints` table](https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html#check-cfg-in-lintsrust-table) to `Cargo.toml`.

```toml
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(coverage_nightly)"] }
```

If you want to ignore all `#[test]`-related code, consider using [coverage-helper] crate version 0.2+.

cargo-llvm-cov excludes code contained in the directory named `tests` from the report by default, so you can also use it instead of coverage-helper crate.
Expand Down

0 comments on commit 746086b

Please sign in to comment.