Urgau

@Urgau

Joined on Dec 8, 2020

  • See the Cargo announcement blog post for more a global view of the feature. This document is intented to summarize the principal ways Cargo interacts with the unexpected_cfgs lint and --check-cfg flag. It is not intended to provide individual details, for that refer to the --check-cfg documentation and to the Cargo book. Cargo always enables checking conditional configurations with Rust 1.80 and upper. This is to help with verifying that the crate is correctly handling conditional compilation for
     Like  Bookmark
  • Summary This adds a new top-level command line option --check-cfg (to rustc and rustdoc) in order to enable checking conditional compilation at compile time. rustc will check every #[cfg(name = "value")], #[cfg_attr(name = "value")], #[link(name = "a", cfg(name = "value"))] attributes and cfg!(name = "value") macro calls. --cfg arguments are not checked[^arg]. [^arg]: For a big part of the existance of the feature, --cfg CLI args were also checked, but given that it interacted badly Cargo RUSTFLAGS, it was removed and left as an future posibility in the documentation. The syntax looks (roughly) like this: rustc --check-cfg 'cfg(name, values("value1", "value2", ... "valueN"))'
     Like  Bookmark
  • Crater report analysis Context: The crater run enable-by-default cargo -Zcheck-cfg and temporarily put the unexpected_cfgs lint to deny-by-default, and here are the results. Affected projects: 6708 / 414692 (1.62%) Total (raw) errors: 200499 50 most seen unexpected cfg errors Summary: no false-positives[^false_positives], see the others section for more details. well, ignoring docsrs (already fixed), rustfmt (deprecated/no longer in use) as well as feature="cargo-clippy" (and feature="clippy")" which are deprecated and should be in the [features] table.
     Like  Bookmark
  • This is in preparation for stabilizing cargo check -Zcheck-cfg as always-on in Cargo. RFC 3013 adds validation to #[cfg] conditionals to help catch typos, stale conditionals, etc. Note: the implementaion has drasticly changed the RFC approval, please always refer to the cargo unstable docs and rustc unstable docs. For cargo users Testing instructions Requires: nightly-2024-02-05 or newer
     Like  Bookmark
  • Was done using hyperfine on an Intel Core i7-7700HQ (4 cores, 3.8GHz max). They represent both extreme, helloworld (0 feature and 1 cfg) and windows-rs (~700 features and >99000 cfgs). windows $ hyperfine --prepare "cargo clean" "cargo +nightly check" "cargo +nightly check -Zcheck-cfg" Benchmark 1: cargo +nightly check Time (mean ± σ): 805.4 ms ± 12.5 ms [User: 675.2 ms, System: 150.8 ms] Range (min … max): 792.1 ms … 824.6 ms 10 runs
     Like  Bookmark
  • Crater report analysis Context: We did a crater run were we temporarily put the lint to deny-by-default, and here are the results. Affected projects: 7057 / 851203 (0.82%) Total errors: 116165 Total errors from derive macros: 107531 (across 259 different derive macros) Total errors from macro_rules!: 2150 (across 117 different macro_rules!) Total errors (manual, not above): 6484
     Like  Bookmark