-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Description
I tried to update a project with the following dependencies:
[dependencies]
diesel = {version = "1.4.7", features = ["postgres"]}
diesel_migrations = "1.4.0"
(Just having an empty project with those dependencies sufficient to reproduce the issue)
I executed the following commands as outlined here:
$ cargo +beta check # to verify that the project builds successful on the 2018 edition
$ cargo +beta fix --edition
$ sed 's/edition = "2018"/edition = "2021"/g' Cargo.toml -i
$ cargo +beta check # to check the projects builds successful on the 2021 edition
I expected to see this happen: Everything succeeds without errors
Instead, this happened: The final check commando fails with error messages
$ cargo +beta fix --edition
note: Switching to Edition 2021 will enable the use of the version 2 feature resolver in Cargo.
This may cause some dependencies to be built with fewer features enabled than previously.
More information about the resolver changes may be found at https://doc.rust-lang.org/nightly/edition-guide/rust-2021/default-cargo-resolver.html
When building the following dependencies, the given features will no longer be used:
diesel v1.4.7 (as host dependency) removed features: 32-column-tables, bitflags, default, postgres, pq-sys, with-deprecated
note: This project appears to use both diesel and diesel_migrations. These packages have
a known issue where the build may fail due to the version 2 resolver preventing
feature unification between those two packages. See
<https://github.com/rust-lang/cargo/issues/9450> for some potential workarounds.
Checking diesel-test-2021 v0.1.0 (/tmp/diesel-test-2021)
Migrating src/main.rs from 2018 edition to 2021
Finished dev [unoptimized + debuginfo] target(s) in 0.31s
$ sed 's/edition = "2018"/edition = "2021"/g' Cargo.toml -i
$ cargo +beta check
Compiling diesel v1.4.7
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:37:48
|
37 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:75:48
|
75 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:96:48
|
96 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:115:48
|
115 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:136:48
|
136 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:155:48
|
155 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:177:48
|
177 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:205:48
|
205 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:248:48
|
248 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:278:48
|
278 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:298:48
|
298 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:313:48
|
313 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0432]: unresolved import `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:336:48
|
336 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:37:48
|
37 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:75:48
|
75 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:96:48
|
96 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:115:48
|
115 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:136:48
|
136 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:155:48
|
155 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:177:48
|
177 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:205:48
|
205 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:248:48
|
248 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:278:48
|
278 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:298:48
|
298 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:313:48
|
313 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0433]: failed to resolve: could not find `pg` in `diesel`
--> /home/weiznich/.cargo/registry/src/github.202132.xyz-1ecc6299db9ec823/diesel-1.4.7/src/sql_types/mod.rs:336:48
|
336 | #[derive(Debug, Clone, Copy, Default, QueryId, SqlType)]
| ^^^^^^^ could not find `pg` in `diesel`
|
= note: this error originates in the derive macro `SqlType` (in Nightly builds, run with -Z macro-backtrace for more info)
Some errors have detailed explanations: E0432, E0433.
For more information about an error, try `rustc --explain E0432`.
note: This error may be due to an interaction between diesel and Cargo's new
feature resolver. Some workarounds you may want to consider:
- Add a build-dependency in Cargo.toml on diesel to force Cargo to add the appropriate
features. This may look something like this:
[build-dependencies]
diesel = { version = "1.4.7", features = ["postgres"] }
- Try using the previous resolver by setting `resolver = "1"` in `Cargo.toml`
(see <https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions>
for more information).
error: could not compile `diesel` due to 26 previous errors
The final error message already gives an indication why this error happens. (As already outlined here and here I feel that this change is nothing that is covered by any edition RFC, as any RFC states that changing the edition should be a crate local change and should not affect any upstream or down stream crates. That's at least in my opinion clearly not the case here. That written I accept that removing this feature from the 2021 edition will likely not happen so let's stop that discussion here 😞 )
To give a more productive indication on how that workflow can be improved:
- In an ideal world
cargo fix --edition
would just fix the problem and either add the corresponding section toCargo.toml
- It would be possible that
cargo fix --edition
just setsresolver = "1"
in theCargo.toml" for edition upgrades and only for new projects the
resolver = "2"feature is used (and that it is set explicitly in the
Cargo.toml` rather than just changing the default) - As another show stop measurement
cargo fix --edition
should emit the same warning ascargo check
already does. As the messaging currently reads it's unclear if the build will fail afterwards or not. Onlycargo check
gives the user a clear indication how to actually fix that problem - As a medium term thing: Rust needs to provide better tools to bundle proc macro crates and other crates.
Meta
rustc --version --verbose
:
rustc 1.56.0-beta.2 (f9a839ea0 2021-09-11)
binary: rustc
commit-hash: f9a839ea0c4c4885a5366d877a75ad3525bbab5e
commit-date: 2021-09-11
host: x86_64-unknown-linux-gnu
release: 1.56.0-beta.2
LLVM version: 13.0.0
Backtrace
<backtrace>
@rustbot label +A-edition-2021