Closed mleonhard closed 3 months ago
The file exists to trigger a compiler error when the user uses an invalid combination of features: https://github.com/serde-rs/json/blob/2e15e3d7d53a68f78ff559709c57e4fa70584bb7/src/features_check/error.rs#L1
https://github.com/serde-rs/json/blob/2e15e3d7d53a68f78ff559709c57e4fa70584bb7/src/features_check/mod.rs#L10-L13
The invalid code interferes with static analysis tools like cargo-geiger:
$ cargo-geiger --version cargo-geiger 0.11.7 $ cargo geiger ... Failed to parse file: /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/features_check/error.rs, Syn(Error("expected one of: `fn`, `extern`, `use`, `static`, `const`, `unsafe`, `mod`, `type`, `struct`, `enum`, `union`, `trait`, `auto`, `impl`, `default`, `macro`, identifier, `self`, `super`, `crate`, `::`"), "/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde_json-1.0.115/src/features_check/error.rs") ...
Let replace the invalid code with a call to the std::compile_error! macro:
std::compile_error!
#[cfg(not(any(feature = "std", feature = "alloc")))] compile_error!("serde_json requires that either `std` (default) or `alloc` feature is enabled");
The file exists to trigger a compiler error when the user uses an invalid combination of features: https://github.com/serde-rs/json/blob/2e15e3d7d53a68f78ff559709c57e4fa70584bb7/src/features_check/error.rs#L1
https://github.com/serde-rs/json/blob/2e15e3d7d53a68f78ff559709c57e4fa70584bb7/src/features_check/mod.rs#L10-L13
The invalid code interferes with static analysis tools like cargo-geiger:
Let replace the invalid code with a call to the
std::compile_error!
macro: