-
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
feat(toml): Warn on unset Edition #13505
Conversation
This is a follow up to 14646e6 I don't run these tests locally, so I missed them.
d56ad4a
to
768c70a
Compare
p.cargo("check -v") | ||
.with_stderr( | ||
"\ | ||
[WARNING] no edition set: defaulting to the 2015 edition while 2018 is compatible with `rust-version` |
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 we call out which package it is? There might be a workspace containing tons of members.
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.
Looks like its done for us:
// In a workspace, it can be confusing where a warning
// originated, so include the path.
format!("{}: {}", path.display(), warning.message)
The other warnings I looked at do not mention the package which is why I dug into it to find that code. The test case must be only for a single package so it gets elided.
Given edition 2015 is quite old, I assume most people won't be flooded with this error messages. If it turns out to be a real problem, we can consider revert. @bors r+ |
☀️ Test successful - checks-actions |
Update cargo 12 commits in 8964c8ccff6e420e2a38b8696d178d69fab84d9d..f772ec0224d3755ce52ac5128a80319fb2eb45d0 2024-02-27 19:22:46 +0000 to 2024-03-01 22:57:35 +0000 - feat(toml): Warn on unset Edition (rust-lang/cargo#13505) - fix(msrv): Report all incompatible packages, not just a random one (rust-lang/cargo#13514) - refactor: abstract `std::fs` away from on-disk index cache (rust-lang/cargo#13515) - chore(deps): update compatible (rust-lang/cargo#13507) - chore(deps): update rust crate rusqlite to 0.31.0 (rust-lang/cargo#13510) - [docs]: Clarify vendored sources as read-only and way to modify (rust-lang/cargo#13512) - chore(deps): update rust crate supports-hyperlinks to v3 (rust-lang/cargo#13511) - refactor: Clarify more Config -> Context (rust-lang/cargo#13506) - test: Make `edition` explicit in packages (rust-lang/cargo#13504) - Add all unit's children recursively for `doc.extern-map` option (rust-lang/cargo#13481) - fix(rustc): Always pass --edition to rustc (rust-lang/cargo#13499) - Silently ignore `cargo::rustc-check-cfg` to avoid MSRV annoyance when stabilizing `-Zcheck-cfg` (rust-lang/cargo#13438) r? ghost
Is it possible to silence this warning to the workspace contains a crate that have rust-version < 1.31? I don't think this warning is useful at all for crates with MSRV lower than 1.31, as adding the edition will break the MSRV. |
That sounds reasonable. However the |
rust-version field is just ignored on old cargo. This means a crate with old MSRV can have rust-version field. For example: https://github.com/serde-rs/serde/blob/v1.0.179/serde/Cargo.toml#L14 |
Isn't this the same as setting Yet I understand that Cargo should be smarter to infer |
$ cat Cargo.toml
[package]
name = "repro"
version = "0.1.0"
edition = "2015"
$ cargo +1.27 build
error: failed to parse manifest at `/Users/taiki/projects/tmp/repro/Cargo.toml`
Caused by:
editions are unstable
Caused by:
feature `edition` is required
this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["edition"]` to enable this feature Most previously unstable fields have similar properties (e.g., #10954), but the https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
(Assuming you are talking about a crate like: MSRV is 1.20 but the edition is 2018.) Also, specifying MSRV older than the edition in the https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field
|
fix(toml): Don't warn on unset Edition if only 2015 is compatible ### What does this PR try to resolve? The warning doesn't help towards the stated goal if the only MSRV-compatible Edition is 2015 (plus, if you're MSRV is that old, you likely know better). This also fixes a problem in #13505 where we were suggesting to set a field that might require an MSRV bump which may be unactionable to silence and we avoid warnings without an actionable way of silencing until #12235 gives us a general means. ### How should we test and review this PR? ### Additional information This was discussed in - #13505 - https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/warn.20on.20missing.20.60edition.60.20field.20in.20Cargo.2Etoml
This is a follow up to 14646e6 and it would fix warnings while migrating jobserver tests to snapbox. see [feat(toml): Warn on unset Edition rust-lang#13505](rust-lang#13504)
This is a follow up to 14646e6 and it would fix warnings while migrating jobserver tests to snapbox. see [feat(toml): Warn on unset Edition rust-lang#13505](rust-lang#13505)
This eliminates the warning message "[WARNING] no edition set: ..." introduced in rust-lang#13505.
What does this PR try to resolve?
On Internals, the idea came up for warning on unset Edition.
Besides helping people who forget to set the Edition, this creates symmetry between
Cargo.toml
and cargo scripts (#12207). While the default is different in each case, we are making the default obvious and guiding people away from it.How should we test and review this PR?
There are separate commits for adding tests (and refactors) so the changes in behavior will be more obvious
Additional information
This builds on
edition
explicit in packages #13504