-
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): Clean up workspace inheritance #12971
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
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
This seems pretty neat! I'd like to hand this to @Muscraft to see if they have any feedback. r? Mustcraft |
Failed to set assignee to
|
r? Muscraft |
12b9fd4
to
46d9894
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.
Thanks!
This makes it easier to understand and reason about what is going on!
@bors r+ |
☀️ Test successful - checks-actions |
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
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
What does this PR try to resolve?
The goal is to simplify the code so we have a better boundary between
toml/mod.rs
andtoml/schema.rs
for when we breaktoml/schema.rs
into a separate package for #12801.This let us
schema.rs
A 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 errorsInheritableField
has aninherit
function on it. They eagerly inherit things and then error if anything isn't inheritedInheritableField
has aninherit_with
function, like today, that only passes errors up but doesn't generate an error. We then have aget
function that errors if it isn't inherited. We could encode the field names, for error reporting, into a type parameter forInheritableField
InheritableDependency
intoTomlDependency
workspace.dependencies
and.cargo/config.toml
code can directly useTomlDependency
without extra error handling-If we went this rout, I think I'd merge
InheritableDependency::Inherit
withDetailedDependency
, having callers handle the errors (much likeTomlManifest
is both a real and virtual)Some things I'm trying to balance
How should we test and review this PR?
Additional information