-
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
refactor(toml): Pull out the schema #12911
Conversation
Remaining steps - Decouple `toml/mod.rs` functionality from `toml/schema.rs` - Pull out `core/` types referenced by `toml/schema.rs`
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
11bcc2b
to
547f7d9
Compare
Just to confirm, this just moves things, there aren't any other changes of substance? If so, it sounds good to me. However, I'd like to defer to @weihanglo to see what they would like. r? @weihanglo |
Correct. The most visible changes are for cargo-as-a-library users
|
547f7d9
to
9a1bbc9
Compare
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.
The module name doesn't catch my eye. toml::schema
looks pretty genernal that we might also want config.toml
to be inside. I don't think that's the better direction, but is it in the plan in your mind?
Thats been a problem for This doesn't try to solve it. I laid out my plan within the PR description. Currently, I have the package name as EDIT: PR description is 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.
While I left two comments about the visibility of seemingly internal only fields, I am going to merge this to unblock stuff.
|
||
/// Provide a helpful error message for a common user error. | ||
#[serde(rename = "cargo-features", skip_serializing)] | ||
pub _invalid_cargo_features: Option<InvalidCargoFeatures>, |
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.
What is the use case of making this public?
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.
That depends on if we want this to be #[non_exhaustive]
or directly constructable. For now, I was going with directly constructable.
/// This is here to provide a way to see the "unused manifest keys" when deserializing | ||
#[serde(skip_serializing)] | ||
#[serde(flatten)] | ||
pub unused_keys: BTreeMap<String, toml::Value>, |
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.
This seems like for emitting a better warning only. Do we want to pub this?
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.
- Callers might want to collect unused keys
- See above about
#[non_exhaustive]
Worth noting that, making fields and types @bors r+ |
refactor(toml): Pull out the schema ### What does this PR try to resolve? On its own, this PR is a net negative for readability / complexity. It moves all of the serde types related to manifest from `toml/mod.rs` to `toml/schema.rs`, leaving a lot of the functions and some trait implementations back in `toml/mod.rs` (some basic functions that made sense for the type on their own were also moved). So why do this? This is an ooch towards having the schema broken out into a separate package (#12801). To do this, we need to - Identify what all types need to be put in the package. This refactor highlights the dependence on `RustVersion` and `PackageIdSpec` - Highlights what functionality we need to find a new home for Follow up PRs would - Find better homes for the logic in `toml/mod.rs`, moving us away from having `impl schema::Type` blocks. - Pull out a `src/cargo/util_semver` package to own `PartialVersion` (at least) as prep for making a `cargo-util-semver` package - Move `RustVersion` to `manifest-toml/schema.rs`, deciding what functionality needs to move with the type - Move or copy `PackageIdSpec` into `manfest-toml/schema.rs`, deciding what functionality remain in `core/` and what moves over - Move `toml/schema.rs` to `src/cargo/util_schema` - Actually make `cargo-util-semver` and `cargo-util-manifest-schema` packages So why do this now? This is a big change! By being incremental - Reduce churn for me and others - Be easier to review - Collect feedback as we go on the whole plan to avoid more painful changes later We *can* back this out if needed but the further we go, the more painful it will be. ### How should we test and review this PR? ### Additional information
💔 Test failed - checks-actions |
Blocked on #12921 |
@bors retry |
☀️ Test successful - checks-actions |
Update cargo 7 commits in 65e297d1ec0dee1a74800efe600b8dc163bcf5db..7046d992f9f32ba209a8079f662ebccf9da8de25 2023-11-03 20:56:31 +0000 to 2023-11-08 03:24:57 +0000 - fix: Report more detailed semver errors (rust-lang/cargo#12924) - Fix some broken links in the man pages (rust-lang/cargo#12929) - Add better error message when it can not find the search section (rust-lang/cargo#12865) - Bug 12920 (rust-lang/cargo#12923) - Update link in environment-variables.md (rust-lang/cargo#12922) - refactor(toml): Pull out the schema (rust-lang/cargo#12911) - tests: Remove plugin tests (rust-lang/cargo#12921) r? ghost
What does this PR try to resolve?
On its own, this PR is a net negative for readability / complexity. It moves all of the serde types related to manifest from
toml/mod.rs
totoml/schema.rs
, leaving a lot of the functions and some trait implementations back intoml/mod.rs
(some basic functions that made sense for the type on their own were also moved).So why do this? This is an ooch towards having the schema broken out into a separate package (#12801). To do this, we need to
RustVersion
andPackageIdSpec
Follow up PRs would
toml/mod.rs
, moving us away from havingimpl schema::Type
blocks.src/cargo/util_semver
package to ownPartialVersion
(at least) as prep for making acargo-util-semver
package (refactor(util): Pull outmod util_semver
#12940)RustVersion
tomanifest-toml/schema.rs
, deciding what functionality needs to move with the typePackageIdSpec
intomanfest-toml/schema.rs
, deciding what functionality remain incore/
and what moves overtoml/schema.rs
tosrc/cargo/util_schema
cargo-util-semver
andcargo-util-manifest-schema
packagesSo why do this now? This is a big change! By being incremental
We can back this out if needed but the further we go, the more painful it will be.
How should we test and review this PR?
Additional information