From: bors Date: Mon, 6 Jan 2020 15:20:09 +0000 (+0000) Subject: Auto merge of #7748 - ehuss:fix-config-env-var-prefix, r=alexcrichton X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=f7c5b1f8395cad94127aa70667f69271750d941c;p=cargo.git Auto merge of #7748 - ehuss:fix-config-env-var-prefix, r=alexcrichton Fix config env vars that are prefix of another with underscore. This fixes the CARGO_BUILD_TARGET_DIR and CARGO_PROFILE_DEV_DEBUG_ASSERTIONS environment variables. Hopefully the big comment explains everything, but to review: `deserialize_option` does not know the type of the value it is about to deserialize. The type could be a struct, in which case it needs to check if `CARGO_FOO_BAR_*` environment variables are set. However, when deserializing something like `build.target`, this prefix check will incorrectly match `CARGO_BUILD_TARGET_DIR` which happens to be a prefix of `CARGO_BUILD_TARGET_*`. It attempts to call `visit_some` which fails if `CARGO_BUILD_TARGET` is not set. The solution here is to detect scenarios where one field is a prefix of another, and skip the environment prefix check (by setting `Deserializer::env_prefix_ok` appropriately). This means we cannot have `Option` be a prefix of another field with an underscore. I think that's fine, and we should try to probably avoid these kinds a prefixes anyways. Closes #7253. --- f7c5b1f8395cad94127aa70667f69271750d941c