-
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
Normalization of Cargo.toml
can break crates with deps. that read Cargo.toml
#13191
Comments
With my super-stickler hat on, comments in TOML are not syntactically meaningful. Without that hat on, I still feel this is likely in |
Having a "blessed" way to write feature descriptions definitely sounds like an all-around better solution!
Agreed; I have already encouraged |
document-features already fallbacks to Cargo.toml.orig. I think the problem happens when the dependencies end up vendored. Not sure what tools their using that removes the Cargo.toml.orig. But I agree it was too strong to throw an error from the document-features macro. |
As this is relying on non-syntactic content and the cost to paper over this to help with these applications would be great, I'm going to propose to the rest of the cargo team that we close this. |
Agree, and since |
AFAIK, neither Mozilla nor my reproducible example in the OP change files; it seems that |
Hmm… I didn't look closer. Seems like Lines 341 to 348 in 363a2d1
We may want to reconsider copying |
Problem
Commentary surrounding items in a crate's
Cargo.toml
is stripped whencargo package
orcargo vendor
are used to vendor in said crate. For most crates, this does not cause a problem. However, this can cause build regressions or changes for crates with dependencies that useCargo.toml
's contents. As a concrete example of this happening,document-features
usesCargo.toml
to emit documentation for features. However, a few users of crates that consumedocument-features
indirectly have found thatcargo vendor
copies of crates run into build regressions (see alsoslint-ui/document-features
#20), because feature commentary is missing from the "normalized"Cargo.toml
manifests.Steps
First, create a "dependency" crate that depends on
document_features
0.2.7, uses itsdocument_features!(…)
macro, and which has at least one "documented" dependency according todocument-features
' convention. For the purposes of these steps, it is important that this crate be readily vendor-able viacargo vendor
, hence a Git repo will be recommended from this point forward.For convenience, one can just use the provided minimum reproducible example "dependency" crate at https://gitlab.com/erichdongubler-mre/2023-12-cargo-toml-normalization-breakage.
Cargo.toml
:src/lib.rs
:Next, create the "consumer" crate, which depends on the "dependency" crate
For convenience, one can use this
Cargo.toml
file as a replacement for a crate otherwise generated withcargo new --lib …
; continuing with thelib
crate as defined above:Run compiler checks against the "consumer" crate with
cargo check
. Observe that it succeeds.Vendor in the "dependency" crate as a dependency of the "consumer" crate. Continuing the above examples, one can use a
.cargo/config.toml
file in the "consumer" file tree like the following:As in step 3, run compiler checks against the "consumer" crate with
cargo check
. Observe that it fails with an error like the following:Possible Solution(s)
My suggestion is to preserve commentary for different sections as possible. In the concrete case of offered reproduction steps, preserving the contents of commentary in the
[features]
section would fix the issue. I don't know what to recommend in the cases where the preservation of originalCargo.toml
structure cannot be achieved, though.Alternatively, Cargo can change its documentation to disclaim that commentary in
Cargo.toml
may be purged withcargo package
orcargo vendor
, and that crate authors should not rely upon it. This would break the ecosystem that currently exists, but would provide a clear guarantee going forward.Notes
Related issue for
document-features
as a "dependency" crate:slint-ui/document-features
#20Version
The text was updated successfully, but these errors were encountered: