#13958 introduce a duplication in the code between the fingerprint logic and the check-cfg lint config, because of Cargo MSRV, the --check-cfg code generation is dependant on a minimum rustc version (1.79).
It would be good to consolidate
|
// Include all the args from `[lints.rust.unexpected_cfgs.check-cfg]` |
|
// |
|
// HACK(#13975): duplicating the lookup logic here until `--check-cfg` is supported |
|
// on Cargo's MSRV and we can centralize the logic in `lints_to_rustflags` |
|
let mut lint_check_cfg = Vec::new(); |
|
if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { |
|
if let Some(rust_lints) = lints.get("rust") { |
|
if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { |
|
if let Some(config) = unexpected_cfgs.config() { |
|
if let Some(check_cfg) = config.get("check-cfg") { |
|
if let Ok(check_cfgs) = |
|
toml::Value::try_into::<Vec<String>>(check_cfg.clone()) |
|
{ |
|
lint_check_cfg = check_cfgs; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
and
|
// Also include the custom arguments specified in `[lints.rust.unexpected_cfgs.check_cfg]` |
|
if let Ok(Some(lints)) = unit.pkg.manifest().resolved_toml().resolved_lints() { |
|
if let Some(rust_lints) = lints.get("rust") { |
|
if let Some(unexpected_cfgs) = rust_lints.get("unexpected_cfgs") { |
|
if let Some(config) = unexpected_cfgs.config() { |
|
if let Some(check_cfg) = config.get("check-cfg") { |
|
if let Ok(check_cfgs) = |
|
toml::Value::try_into::<Vec<String>>(check_cfg.clone()) |
|
{ |
|
for check_cfg in check_cfgs { |
|
args.push(OsString::from("--check-cfg")); |
|
args.push(OsString::from(check_cfg)); |
|
} |
|
// error about `check-cfg` not being a list-of-string |
|
} else { |
|
bail!("`lints.rust.unexpected_cfgs.check-cfg` must be a list of string"); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
in
|
fn lints_to_rustflags(lints: &manifest::TomlLints) -> Vec<String> { |
Originate from #13958 (comment)
#13958 introduce a duplication in the code between the fingerprint logic and the
check-cfglint config, because of Cargo MSRV, the--check-cfgcode generation is dependant on a minimumrustcversion (1.79).It would be good to consolidate
cargo/src/cargo/core/compiler/fingerprint/mod.rs
Lines 1424 to 1443 in 431db31
cargo/src/cargo/core/compiler/mod.rs
Lines 1363 to 1384 in 2415192
cargo/src/cargo/util/toml/mod.rs
Line 2333 in 2415192
Originate from #13958 (comment)