Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs to suggest adding kani to list of known configs #3197

Closed
zhassan-aws opened this issue May 21, 2024 · 0 comments · Fixed by #3198
Closed

Update docs to suggest adding kani to list of known configs #3197

zhassan-aws opened this issue May 21, 2024 · 0 comments · Fixed by #3198
Assignees
Labels
[C] Documentation Additions and improvements to our documentation [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one.

Comments

@zhassan-aws
Copy link
Contributor

Code that includes #[cfg(kani)] in crates that use the nightly-2024-05-05 toolchain or later (or using the yet-to-be-released Rust v1.80), will get a warning. Here's a reproducer:

$ cargo new cfg-warn
     Created binary (application) `cfg-warn` package
$ cd cfg-warn/
$ echo "nightly-2024-05-21" > rust-toolchain

Add the following to src/main.rs:

fn main() { }

#[cfg(kani)]
mod kani_checks {
    #[kani::proof]
    fn check() {
        assert_eq!(1, 1);
    }
}
$ cargo build
info: syncing channel updates for 'nightly-2024-05-21-x86_64-unknown-linux-gnu'
info: latest update on 2024-05-21, rust version 1.80.0-nightly (b92758a9a 2024-05-20)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'
   Compiling cfg-warn v0.1.0 (/home/ubuntu/examples/cfg-warn)
warning: unexpected `cfg` condition name: `kani`
 --> src/main.rs:3:7
  |
3 | #[cfg(kani)]
  |       ^^^^
  |
  = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, `windows`
  = help: consider using a Cargo feature instead
  = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
           [lints.rust]
           unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }
  = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(kani)");` to the top of the `build.rs`
  = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
  = note: `#[warn(unexpected_cfgs)]` on by default

warning: `cfg-warn` (bin "cfg-warn") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s

We should update our docs to suggest adding kani to the list of known configurations in the Cargo.toml file if cfg(kani) is used. For example, adding the following will silence the warning:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] }
$ cargo build
   Compiling cfg-warn v0.1.0 (/home/ubuntu/examples/cfg-warn)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s

Link to relevant documentation (Rust reference, Nomicon, RFC):

https://github.com/rust-lang/rust/blob/b92758a9aef1cef7b79e2b72c3d8ba113e547f89/src/doc/rustc/src/check-cfg/cargo-specifics.md#check-cfg-in-lintsrust-table

@zhassan-aws zhassan-aws added [C] Feature / Enhancement A new feature request or enhancement to an existing feature. [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one. [C] Documentation Additions and improvements to our documentation and removed [C] Feature / Enhancement A new feature request or enhancement to an existing feature. labels May 21, 2024
@remi-delmas-3000 remi-delmas-3000 self-assigned this May 22, 2024
remi-delmas-3000 added a commit that referenced this issue May 22, 2024
Resolves #3197 

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

Co-authored-by: Remi Delmas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C] Documentation Additions and improvements to our documentation [E] User Experience An UX enhancement for an existing feature. Including deprecation of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants