-
Notifications
You must be signed in to change notification settings - Fork 2.7k
refactor: embed deserialize validation logic in ProgressConfig #16194
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
Conversation
src/cargo/util/context/mod.rs
Outdated
| formatter.write_str("a string (\"auto\" or \"never\") or a table") | ||
| } | ||
|
|
||
| fn visit_str<E>(self, s: &str) -> Result<Self::Value, E> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should fn expecting be updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and anyway it is eventually removed.
Also rebased onto master.
I am going to hit the merge button.
|
Feel free to merge when the mentioned issue is addressed |
### What does this PR try to resolve? Make config schema types a bit more outstanding from the way-too-long `context/mod.rs` module. The long-term(-and-hard-to-achieve) is to make a similar crate like `cargo-util-schemas` for config, or just make these schemas into `cargo-util-schemas`. ### How to test and review this PR? This may conflict with #16194
This comment has been minimized.
This comment has been minimized.
This was claimed supported in rust-lang#8165 (comment) but actually it never is. Tested with 1.50 Cargo and it failed with the same reason. It never worked because our custom `Deserializer::deserialize_option` never called `visit_str`. See https://github.com/rust-lang/cargo/blob/c369b8c8d85a/src/cargo/util/config/de.rs#L135-L145
It never worked because our custom `Deserializer::deserialize_option` never called `visit_str`. See https://github.com/rust-lang/cargo/blob/c369b8c8d85a/src/cargo/util/config/de.rs#L135-L145
For an Option the default is always `None`. The default `term.progress` will be provided via `unwrap_or_default` at https://github.com/rust-lang/cargo/blob/4406c1b96413/src/cargo/util/context/mod.rs?plain=1#L1151
This makes the deserialization logic embedded in type itself, rather than relying on parent struct
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Update cargo submodule 22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f 2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000 - fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223) - refactor: Remove lazycell (rust-lang/cargo#16224) - refactor: extract ConfigValue to its own module (rust-lang/cargo#16222) - fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220) - fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213) - fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125) - fix: non-mergeable list from config cli merge the same way (rust-lang/cargo#16219) - docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216) - fix: Remove build-plan (rust-lang/cargo#16212) - Add native completions for `--package` on various commands (rust-lang/cargo#16210) - fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215) - refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177) - docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211) - docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205) - feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203) - chore: Update dependencies (rust-lang/cargo#16200) - chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190) - chore(deps): update msrv (rust-lang/cargo#16178) - refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194) - refactor(gctx): extract config schema to a module (rust-lang/cargo#16195) - chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191) - chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186) r? ghost
Update cargo submodule 22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f 2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000 - fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223) - refactor: Remove lazycell (rust-lang/cargo#16224) - refactor: extract ConfigValue to its own module (rust-lang/cargo#16222) - fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220) - fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213) - fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125) - fix: non-mergeable list from config cli merge the same way (rust-lang/cargo#16219) - docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216) - fix: Remove build-plan (rust-lang/cargo#16212) - Add native completions for `--package` on various commands (rust-lang/cargo#16210) - fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215) - refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177) - docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211) - docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205) - feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203) - chore: Update dependencies (rust-lang/cargo#16200) - chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190) - chore(deps): update msrv (rust-lang/cargo#16178) - refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194) - refactor(gctx): extract config schema to a module (rust-lang/cargo#16195) - chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191) - chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186) r? ghost
What does this PR try to resolve?
We have a custom
serde(deserialize_with = "progress_or_string")to supportterm.progress = "never" | "auto" | <progress table>.It was claimed we added in #8165 1 but actually never worked,
because
Deserializer::deserialize_option2 never calledvisit_str.This PR remove the custom
progress_or_stringso that the deserialization logic can be baked in the type itself.
How to test and review this PR?
I've tested 1.50 Cargo and
progress = "never"failed with the same reason as the newly added test.Footnotes
https://github.com/rust-lang/cargo/pull/8165#issuecomment-693620188 ↩
https://github.com/rust-lang/cargo/blob/c369b8c8d85a/src/cargo/util/config/de.rs#L135-L145 ↩