Skip to content
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

Warn when an edition 2021 crate is in a virtual workspace with default resolver #10910

Merged
merged 7 commits into from
May 26, 2023

Conversation

Nemo157
Copy link
Member

@Nemo157 Nemo157 commented Jul 28, 2022

Edition 2021 updates the default resolver to version "2", but developers using virtual workspaces commonly don't get this update because the virtual workspace defaults to version "1". Warn when this situation occurs so those developers can explicitly configure their workspace and will be more likely to know that they will need to update it in the future.

Fixes #10112

@rust-highfive
Copy link

r? @ehuss

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2022
@Nemo157
Copy link
Member Author

Nemo157 commented Jul 28, 2022

This is mostly a problem for binary packages, but it does also affect library packages in some situations; e.g. it can cause issues when a different resolver is used while building the docs on docs.rs than when building in the projects CI: tokio-rs/axum#1180

src/cargo/core/workspace.rs Outdated Show resolved Hide resolved
src/cargo/core/workspace.rs Outdated Show resolved Hide resolved
@Nemo157
Copy link
Member Author

Nemo157 commented Jul 29, 2022

I'll update this based on the discussion in #10112 tomorrow.

@bors
Copy link
Contributor

bors commented Aug 10, 2022

☔ The latest upstream changes (presumably #10961) made this pull request unmergeable. Please resolve the merge conflicts.

@Nemo157 Nemo157 force-pushed the lint-different-resolver-10112 branch from 79f3229 to 1ed5869 Compare August 10, 2022 17:46
src/cargo/core/workspace.rs Outdated Show resolved Hide resolved
src/cargo/core/workspace.rs Outdated Show resolved Hide resolved
@Nemo157 Nemo157 changed the title Warn on any inconsistency in workspace and package resolver Warn when an edition 2021 crate is in a virtual workspace with default resolver Aug 10, 2022
@weihanglo weihanglo added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 14, 2022
@weihanglo
Copy link
Member

Ping @Nemo157. Just checking in to see if you have time and are still interested in working on this. If you have any question, feel free to discuss here or on Zulip.

Nemo157 added 3 commits May 26, 2023 16:11
…t resolver

Edition 2021 updates the default resolver to version "2", but developers
using virtual workspaces commonly don't get this update because the
virtual workspace defaults to version "1". Warn when this situation
occurs so those developers can explicitly configure their workspace and
will be more likely to know that they will need to update it in the
future.
@Nemo157 Nemo157 force-pushed the lint-different-resolver-10112 branch from 1ed5869 to 620f66f Compare May 26, 2023 14:41
@rustbot rustbot added the A-workspaces Area: workspaces label May 26, 2023
@Nemo157
Copy link
Member Author

Nemo157 commented May 26, 2023

Sorry about the delay, I finally got around to rebasing and implemented both suggestions from above.

Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what your thoughts are on another round for tweaking the messages

I look forward to #12115 since it will open the door for more cargo warnings and we'll be able to have a broader mismatch warning that people can disable.

tests/testsuite/features2.rs Outdated Show resolved Hide resolved
tests/testsuite/features2.rs Outdated Show resolved Hide resolved
@Nemo157 Nemo157 force-pushed the lint-different-resolver-10112 branch from 9e86985 to 49cc60b Compare May 26, 2023 18:21
@epage
Copy link
Contributor

epage commented May 26, 2023

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented May 26, 2023

📌 Commit 3dec6f2 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. labels May 26, 2023
@bors
Copy link
Contributor

bors commented May 26, 2023

⌛ Testing commit 3dec6f2 with merge d08c587...

@bors
Copy link
Contributor

bors commented May 26, 2023

☀️ Test successful - checks-actions
Approved by: epage
Pushing d08c587 to master...

@bors bors merged commit d08c587 into rust-lang:master May 26, 2023
@Nemo157 Nemo157 deleted the lint-different-resolver-10112 branch May 26, 2023 21:03
@ehuss
Copy link
Contributor

ehuss commented May 27, 2023

Thanks @Nemo157 for picking this back up.

@weihanglo I recommend adding resolver = "1" to the rust-lang/rust workspace when you do the next update so that warnings don't start getting generated.

(I recall trying to add resolver = "2" in the past, and it not going well. That should probably be done as a separate PR if anyone wants to try that.)

weihanglo added a commit to weihanglo/rust that referenced this pull request May 30, 2023
rust-lang/cargo#10910 starts emitting warning if resolver is not set
for 2021 edition package. We want to surpress the warning for now.
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2023
Update cargo

17 commits in 64fb38c97ac4d3a327fc9032c862dd28c8833b17..f7b95e31642e09c2b6eabb18ed75007dda6677a0
2023-05-23 18:53:23 +0000 to 2023-05-30 19:25:02 +0000
- chore: detect the channel a PR wants to merge into (rust-lang/cargo#12181)
- refactor: de-depulicate `make_dep_prefix` implementation (rust-lang/cargo#12203)
- Re-enable code_generation test on Windows (rust-lang/cargo#12199)
- docs: add doc comments for git source and friends (rust-lang/cargo#12192)
- test: set retry sleep to 1ms for all tests (rust-lang/cargo#12194)
- fix(add): Reduce the chance we re-format the user's `[features]` table (rust-lang/cargo#12191)
- test(add): Remove expensive test (rust-lang/cargo#12188)
- Add a description of `Cargo.lock` conflicts in the Cargo FAQ (rust-lang/cargo#12185)
- refactor(tests): Reduce cargo-add setup load (rust-lang/cargo#12189)
- Warn when an edition 2021 crate is in a virtual workspace with default resolver (rust-lang/cargo#10910)
- refactor(tests): Reduce cargo-remove setup load (rust-lang/cargo#12184)
- chore: Lexicographically order `-Z` flags (rust-lang/cargo#12182)
- chore(ci): remove temporary fix for rustup 1.24.1 (rust-lang/cargo#12180)
- fix: AIX searches dynamic libraries in `LIBPATH`. (rust-lang/cargo#11968)
- deps: remove unused features from windows-sys (rust-lang/cargo#12176)
- Automatically inherit workspace lints when running cargo new/init (rust-lang/cargo#12174)
- Test that the new `debuginfo` options match between cargo and rustc (rust-lang/cargo#12022)

r? `@ghost`
@ehuss ehuss added this to the 1.72.0 milestone Jun 2, 2023
DaniPopes added a commit to DaniPopes/foundry that referenced this pull request Jun 3, 2023
See rust-lang/cargo#10910, released with Rust 1.70

```
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
```
mattsse pushed a commit to foundry-rs/foundry that referenced this pull request Jun 3, 2023
See rust-lang/cargo#10910, released with Rust 1.70

```
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
```
@epage epage mentioned this pull request Jun 6, 2023
6 tasks
calebzulawski pushed a commit to rust-lang/portable-simd that referenced this pull request Jun 7, 2023
rust-lang/cargo#10910 starts emitting warning if resolver is not set
for 2021 edition package. We want to surpress the warning for now.
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Aug 24, 2023
rust-lang/cargo#10910 starts emitting warning if resolver is not set
for 2021 edition package. We want to surpress the warning for now.
thomcc pushed a commit to tcdi/postgrestd that referenced this pull request Aug 24, 2023
Update cargo

17 commits in 64fb38c97ac4d3a327fc9032c862dd28c8833b17..f7b95e31642e09c2b6eabb18ed75007dda6677a0
2023-05-23 18:53:23 +0000 to 2023-05-30 19:25:02 +0000
- chore: detect the channel a PR wants to merge into (rust-lang/cargo#12181)
- refactor: de-depulicate `make_dep_prefix` implementation (rust-lang/cargo#12203)
- Re-enable code_generation test on Windows (rust-lang/cargo#12199)
- docs: add doc comments for git source and friends (rust-lang/cargo#12192)
- test: set retry sleep to 1ms for all tests (rust-lang/cargo#12194)
- fix(add): Reduce the chance we re-format the user's `[features]` table (rust-lang/cargo#12191)
- test(add): Remove expensive test (rust-lang/cargo#12188)
- Add a description of `Cargo.lock` conflicts in the Cargo FAQ (rust-lang/cargo#12185)
- refactor(tests): Reduce cargo-add setup load (rust-lang/cargo#12189)
- Warn when an edition 2021 crate is in a virtual workspace with default resolver (rust-lang/cargo#10910)
- refactor(tests): Reduce cargo-remove setup load (rust-lang/cargo#12184)
- chore: Lexicographically order `-Z` flags (rust-lang/cargo#12182)
- chore(ci): remove temporary fix for rustup 1.24.1 (rust-lang/cargo#12180)
- fix: AIX searches dynamic libraries in `LIBPATH`. (rust-lang/cargo#11968)
- deps: remove unused features from windows-sys (rust-lang/cargo#12176)
- Automatically inherit workspace lints when running cargo new/init (rust-lang/cargo#12174)
- Test that the new `debuginfo` options match between cargo and rustc (rust-lang/cargo#12022)

r? `@ghost`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-workspaces Area: workspaces S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add lint to explicitly set resolver in a virtual workspace
8 participants