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

Compilation fails inside serde macro #2595

Closed
Sycration opened this issue Aug 21, 2023 · 3 comments
Closed

Compilation fails inside serde macro #2595

Sycration opened this issue Aug 21, 2023 · 3 comments

Comments

@Sycration
Copy link

All of this is on the rust:1.71 docker image:

Running cargo install sqlx-cli --no-default-features --features rustls,postgres fails with a strange error:

24.86 error[E0507]: cannot move out of `*self` which is behind a shared reference
24.86   --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.14.2/src/diagnostic.rs:95:24
24.86    |
24.86 95 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
24.86    |                        ^^^^^^^^^
24.86    |                        |
24.86    |                        data moved here
24.86    |                        move occurs because `unrecognized` has type `Applicability`, which does not implement the `Copy` trait
24.86    |
24.86    = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
24.86 help: consider borrowing here
24.86    |
24.86 95 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)]
24.86    |                        +
24.86 
24.91 error[E0507]: cannot move out of `*self` which is behind a shared reference
24.91    --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.14.2/src/messages.rs:101:24
24.91     |
24.91 101 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
24.91     |                        ^^^^^^^^^
24.91     |                        |
24.91     |                        data moved here
24.91     |                        move occurs because `unrecognized` has type `Message`, which does not implement the `Copy` trait
24.91     |
24.91     = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
24.91 help: consider borrowing here
24.91     |
24.91 101 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)]
24.91     |                        +
24.91 
25.06 For more information about this error, try `rustc --explain E0507`.
25.07 error: could not compile `cargo_metadata` (lib) due to 2 previous errors

full log: log.txt

But running cargo install sqlx-cli --no-default-features --features rustls,postgres --git https://github.com/launchbadge/sqlx --locked succeeds.

full log: log-works.txt

@Sycration
Copy link
Author

I first observed this in launchbadge/sqlx#2704

@Sycration Sycration changed the title Breaking change in serde macro Compilation fails inside serde macro Aug 21, 2023
@oli-obk
Copy link
Member

oli-obk commented Aug 21, 2023

I believe this was fixed in https://github.com/serde-rs/serde/releases/tag/v1.0.185 so you may just have to cargo update

@oli-obk
Copy link
Member

oli-obk commented Aug 21, 2023

Duplicate of #2592

@oli-obk oli-obk marked this as a duplicate of #2592 Aug 21, 2023
@oli-obk oli-obk closed this as completed Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants