refactor(toml): Clean up workspace inheritance#12971
Merged
bors merged 5 commits intorust-lang:masterfrom Nov 17, 2023
Merged
Conversation
`Workspace` and `MaybeWorkspace` doesn't make the intent as clear. Generally when talking about this, we say that it "inherits". This also better matches the terms in `cargo_toml` and `cargo-manifest` packages.
This allows us to move bookkeeping / logic out of the schema
Collaborator
|
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
weihanglo
reviewed
Nov 14, 2023
Member
|
This seems pretty neat! I'd like to hand this to @Muscraft to see if they have any feedback. r? Mustcraft |
Collaborator
|
Failed to set assignee to
|
Member
|
r? Muscraft |
12b9fd4 to
46d9894
Compare
Muscraft
approved these changes
Nov 17, 2023
Member
Muscraft
left a comment
There was a problem hiding this comment.
Thanks!
This makes it easier to understand and reason about what is going on!
Member
|
@bors r+ |
Contributor
Contributor
Contributor
|
☀️ Test successful - checks-actions |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 18, 2023
Update cargo 11 commits in 2c03e0e2dcd05dd064fcf10cc1050d342eaf67e3..9765a449d9b7341c2b49b88da41c2268ea599720 2023-11-16 04:21:44 +0000 to 2023-11-17 20:58:23 +0000 - refactor(toml): Clean up workspace inheritance (rust-lang/cargo#12971) - docs: Recommend a wider selection of libsecret-compatible password managers (rust-lang/cargo#12993) - feat(cli): add color output for `cargo --list` (rust-lang/cargo#12992) - refactor: log when loading config from file (rust-lang/cargo#12991) - Link to rustc lint levels (rust-lang/cargo#12990) - chore(ci): Catch naive use of AtomicU64 early (rust-lang/cargo#12988) - cargo-credential-1password: Add missing `--account` argument to `op signin` command (rust-lang/cargo#12985) - chore: dogfood Cargo `-Zlints` table feature (rust-lang/cargo#12178) - cargo-credential-1password: Fix README (rust-lang/cargo#12986) - Fix a rustflags test using a wrong buildfile name (rust-lang/cargo#12987) - Fix some test output validation. (rust-lang/cargo#12982) r? ghost
bors
added a commit
that referenced
this pull request
Nov 20, 2023
refactor(toml): Further clean up inheritance ### What does this PR try to resolve? This is a follow up to #12971 that was found as I continued working towards #12801. The first is a more general purpose API cleanup. I was bothered by the idea that a caller could create a `field.workspace = false` when that is disallowed, so I modified the API to prevent that. The second is part of needing to find a home for everything in `toml/mod.rs`. I figured `IneheritableField::as_value` is reasonable in the API, so I carried that forward. It would be reasonable to add other methods, from an API perspective, but I left that for future exploration. ### How should we test and review this PR? ### Additional information
20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
The goal is to simplify the code so we have a better boundary between
toml/mod.rsandtoml/schema.rsfor when we breaktoml/schema.rsinto a separate package for #12801.This let us
schema.rsA lot of these changes were inspired by
cargo_toml. This included some renaming that I felt made the code clearer.I didn't go as far as
cargo_toml, yet.Deserializers, producing worse errorsInheritableFieldhas aninheritfunction on it. They eagerly inherit things and then error if anything isn't inheritedInheritableFieldhas aninherit_withfunction, like today, that only passes errors up but doesn't generate an error. We then have agetfunction that errors if it isn't inherited. We could encode the field names, for error reporting, into a type parameter forInheritableFieldInheritableDependencyintoTomlDependencyworkspace.dependenciesand.cargo/config.tomlcode can directly useTomlDependencywithout extra error handling-If we went this rout, I think I'd merge
InheritableDependency::InheritwithDetailedDependency, having callers handle the errors (much likeTomlManifestis both a real and virtual)Some things I'm trying to balance
How should we test and review this PR?
Additional information