-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C-cleanupCategory: cleanup within the codebaseCategory: cleanup within the codebase
Description
#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
cargo/src/cargo/core/compiler/fingerprint/mod.rs
Lines 1424 to 1443 in 431db31
// 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; | |
} | |
} | |
} | |
} | |
} | |
} |
cargo/src/cargo/core/compiler/mod.rs
Lines 1363 to 1384 in 2415192
// 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"); | |
} | |
} | |
} | |
} | |
} | |
} |
cargo/src/cargo/util/toml/mod.rs
Line 2333 in 2415192
fn lints_to_rustflags(lints: &manifest::TomlLints) -> Vec<String> { |
Originate from #13958 (comment)
Metadata
Metadata
Assignees
Labels
C-cleanupCategory: cleanup within the codebaseCategory: cleanup within the codebase