-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add named config profiles. #7750
Conversation
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
cc custom named profile tracking issue: #6988 |
This all looks fantastic to me and all the refactorings sound great to me as well. Thanks for writing this all up @ehuss! |
☔ The latest upstream changes (presumably #7776) made this pull request unmergeable. Please resolve the merge conflicts. |
03e3a8d
to
c92f498
Compare
Ping @Eh2406 or @alexcrichton, not sure if either of you can review this, or if there are any questions I can answer or any way I can make the review easier. |
Oh sorry I think the only reason I didn't r+ at the time was maybe it needed a rebase? Or maybe I forgot? In an ycase... @bors: r+ |
📌 Commit c92f4986423d41cbc940b76d6ea0fc61c0c351a4 has been approved by |
⌛ Testing commit c92f4986423d41cbc940b76d6ea0fc61c0c351a4 with merge e3311f94d7a2df7e042dd21c0899158f565d2ab2... |
💔 Test failed - checks-azure |
c92f498
to
dafacbb
Compare
Updated due to formatting changes from |
📌 Commit dafacbb has been approved by |
Add named config profiles. This adds support for named config profiles. Previously, only `dev` and `release` were allowed in config files, it now supports all profile names. I think it would be strange to have arbitrarily named profiles in `Cargo.toml`, but not allow them in config. This is a deviation from the RFC, but RFC 2282 was written before named profiles which I think changes the landscape. This diff is a little large due to some refactoring to make it work well. Overview of the changes: - Removed `ProfileKind` and only use an `InternedString` to track the name of the profile. I didn't feel like the enum carried its cognitive weight, and it seems to simplify some things. - `Profiles` is no longer stored in the manifest. There was no need to do a bunch of processing for each manifest. `Manifest` now only retains the low-level `TomlProfiles`. A single `Profiles` now lives in `BuildContext`. - The profile name requested by the user is no longer passed around. It is given to `Profiles::new` and retained inside `Profiles`. - `Profiles::get_profile` no longer follows the priority stack and inheritance each time a profile is requested. Instead, the profile is computed once (in `Profile::new`) and merged into a single profile. This simplifies getting a profile, and makes it easier to deal with getting the config values in one place. - I switched profile names to be `InternedString` instead of `String`. There's not a strong reason to do this, other than it seemed a little strange to be creating lots of `String`s. - I also added `PartialEq<str>` for `InternedString`. It has come up a few times in the past, and it seems useful. I'm not sure if it was excluded intentionally? - The validation that the profile exists is now done in one place (`Profiles::new`). - I removed the back-compatibility for the `overrides` key (which was renamed to `package` back in October). Notes: - Some of the error messages aren't as good as before, because they don't tell you where the error is located (`Cargo.toml` or `.cargo/config`). This is because the location data is lost by the time validation is done. Hopefully it will be obvious from the profile name and error message. I tried to improve error messages wherever I could. - There are more calls to `clone()` than I would like, but they are kinda hard to avoid. Should be fewer than before. - I noticed a bug with `-Zpanic-abort-tests` not supporting named profiles. I'll fix that separately. - I think this fixes some bugs where package overrides in config weren't merging properly with package overrides defined in `Cargo.toml`.
☀️ Test successful - checks-azure |
Update cargo rls ## cargo 12 commits in 6e1ca924a67dd1ac89c33f294ef26b5c43b89168..ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65 2020-01-06 19:11:37 +0000 to 2020-01-13 21:37:15 +0000 - Add named config profiles. (rust-lang/cargo#7750) - Make cargo-rustc crate-type-aware (rust-lang/cargo#7755) - Rename `Kind` (rust-lang/cargo#7791) - Update bash completion (rust-lang/cargo#7789) - Add another curl spurious network error (rust-lang/cargo#7788) - Some small tweaks around error in configuration (rust-lang/cargo#7783) - Fix tests with `url` crate update (rust-lang/cargo#7787) - Fix .gitignore of Cargo.lock in a subdirectory. (rust-lang/cargo#7779) - Bump crates-io (rust-lang/cargo#7778) - Migrate from the `failure` crate to `anyhow` (rust-lang/cargo#7776) - Fix several needless_borrow clippy lints. (rust-lang/cargo#7771) - Fix some links (rust-lang/cargo#7770) ## rls 2 commits in 7c0489c5ff4f5c594e65a3b22efd9ce373deab9b..b27e1173969639448cd2e486b1c5f0fcb1b3b17c 2020-01-04 20:15:37 +0100 to 2020-01-13 11:40:20 +0100 - Update Cargo (rust-lang/rls#1613) - Rustup to #68024 (rust-lang/rls#1612)
Update cargo rls ## cargo 12 commits in 6e1ca924a67dd1ac89c33f294ef26b5c43b89168..ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65 2020-01-06 19:11:37 +0000 to 2020-01-13 21:37:15 +0000 - Add named config profiles. (rust-lang/cargo#7750) - Make cargo-rustc crate-type-aware (rust-lang/cargo#7755) - Rename `Kind` (rust-lang/cargo#7791) - Update bash completion (rust-lang/cargo#7789) - Add another curl spurious network error (rust-lang/cargo#7788) - Some small tweaks around error in configuration (rust-lang/cargo#7783) - Fix tests with `url` crate update (rust-lang/cargo#7787) - Fix .gitignore of Cargo.lock in a subdirectory. (rust-lang/cargo#7779) - Bump crates-io (rust-lang/cargo#7778) - Migrate from the `failure` crate to `anyhow` (rust-lang/cargo#7776) - Fix several needless_borrow clippy lints. (rust-lang/cargo#7771) - Fix some links (rust-lang/cargo#7770) ## rls 2 commits in 7c0489c5ff4f5c594e65a3b22efd9ce373deab9b..b27e1173969639448cd2e486b1c5f0fcb1b3b17c 2020-01-04 20:15:37 +0100 to 2020-01-13 11:40:20 +0100 - Update Cargo (rust-lang/rls#1613) - Rustup to #68024 (rust-lang/rls#1612)
Fix config profiles using "dev" in `cargo test`. Fix a bug where the "dev" profile was not loaded from config when running `cargo test` when "dev" is not listed in `Cargo.toml`. There was a mistake in #7750 where it did not consider implicit profiles. Config profiles need to be loaded explicitly in order to properly handle environment variables. However, it was only looking at the profile requested on the command-line and those listed in `Cargo.toml`. `cargo test` also implicitly uses the "dev" profile for dependencies, so make sure those are loaded from config as well.
…richton Fix config profiles using "dev" in `cargo test`. Fix a bug where the "dev" profile was not loaded from config when running `cargo test` when "dev" is not listed in `Cargo.toml`. There was a mistake in rust-lang#7750 where it did not consider implicit profiles. Config profiles need to be loaded explicitly in order to properly handle environment variables. However, it was only looking at the profile requested on the command-line and those listed in `Cargo.toml`. `cargo test` also implicitly uses the "dev" profile for dependencies, so make sure those are loaded from config as well.
This adds support for named config profiles. Previously, only
dev
andrelease
were allowed in config files, it now supports all profile names. I think it would be strange to have arbitrarily named profiles inCargo.toml
, but not allow them in config. This is a deviation from the RFC, but RFC 2282 was written before named profiles which I think changes the landscape.This diff is a little large due to some refactoring to make it work well. Overview of the changes:
ProfileKind
and only use anInternedString
to track the name of the profile. I didn't feel like the enum carried its cognitive weight, and it seems to simplify some things.Profiles
is no longer stored in the manifest. There was no need to do a bunch of processing for each manifest.Manifest
now only retains the low-levelTomlProfiles
. A singleProfiles
now lives inBuildContext
.Profiles::new
and retained insideProfiles
.Profiles::get_profile
no longer follows the priority stack and inheritance each time a profile is requested. Instead, the profile is computed once (inProfile::new
) and merged into a single profile. This simplifies getting a profile, and makes it easier to deal with getting the config values in one place.InternedString
instead ofString
. There's not a strong reason to do this, other than it seemed a little strange to be creating lots ofString
s.PartialEq<str>
forInternedString
. It has come up a few times in the past, and it seems useful. I'm not sure if it was excluded intentionally?Profiles::new
).overrides
key (which was renamed topackage
back in October).Notes:
Cargo.toml
or.cargo/config
). This is because the location data is lost by the time validation is done. Hopefully it will be obvious from the profile name and error message. I tried to improve error messages wherever I could.clone()
than I would like, but they are kinda hard to avoid. Should be fewer than before.-Zpanic-abort-tests
not supporting named profiles. I'll fix that separately.Cargo.toml
.