在`Cargo.toml` 中定义的 `feature` 会被`Cargo` 通过命令行参数 `--cfg` 传给`rustc`,最终由后者完成编译:`rustc --cfg ...`。若项目中的代码想要测试 `feature` 是否存在,可以使用 [`cfg` 属性](https://doc.rust-lang.org/stable/reference/conditional-compilation.html#the-cfg-attribute)或[`cfg...
fn main() { println!( r#"cargo::rustc-check-cfg=cfg(derive_deftly_dprint) cargo::rustc-check-cfg=cfg(feature, values("bizarre"))"# ); } Expected output: it compiles. Actual output: error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but...
Automatically emit rustc-check-cfg directives for AutoCfg #70 Merged cuviper merged 6 commits into cuviper:master from Techcable:feature/rustc-check-cfg Sep 27, 2024 +147 −11 Conversation 13 Commits 6 Checks 24 Files changed 6 Conversation Contributor Techcable commented Sep 10, 2024...
Problem: In Rust 1.80, cfg values other than Cargo feature flags must be communicated to Rust: Automatic checking of cfgs at compile-time. Without that, I believe we'll see warnings. Solution: I think we need build.rs files for every cra...
Some of these look like genuine issues (such as embassy-sync referring to feature = "wasm", which is not defined), but for others I'm not sure (such as embassy-stm32 referring to cfgs such as time, rcc_f400 or flash_g4). Output of `cargo check` in embassy-stm32 honzasp force...
#[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { use self::Error::*; Expand Down 2 changes: 0 additions & 2 deletions 2 bitcoin/src/amount.rs...