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

cargo fix --edition breaks on serde deserialize_with attributes #87578

Closed
Kixunil opened this issue Jul 29, 2021 · 3 comments
Closed

cargo fix --edition breaks on serde deserialize_with attributes #87578

Kixunil opened this issue Jul 29, 2021 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@Kixunil
Copy link
Contributor

Kixunil commented Jul 29, 2021

I tried this code:

#[derive(Debug, Deserialize)]
struct OwnedPair<T>(
    T,
    #[serde(deserialize_with = "::serde_utils::hex_bytes::deserialize")]
    Vec<u8>,
);

And cargo fix --edition

I expected to see this happen: the code gets fixed

Instead, this happened: It attempted to fix it like this: #[serde(deserialize_with = crate::"::serde_utils::hex_bytes::deserialize")] and obviously failed.

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Same happens on nightly, 1.36, and 1.48

Context: I tried to convert https://github.com/rust-bitcoin/rust-bitcoin/ to edition 2018

@Kixunil Kixunil added the C-bug Category: This is a bug. label Jul 29, 2021
@Kixunil
Copy link
Contributor Author

Kixunil commented Jul 29, 2021

Note that after manually fixing bitcoin and applying --edition-idioms I get more errors - it seems to duplicate lifetime markers like this: <'_><'_>.

Kixunil added a commit to Kixunil/rust-bitcoin that referenced this issue Jul 29, 2021
This is the result of running:
```
cargo +1.36.0 fix --edition --all --broken-code --features="base64,rand,use-serde"
```

And manually fixing [cargo fix
bug](rust-lang/rust#87578)
@ehuss
Copy link
Contributor

ehuss commented Jul 29, 2021

Thanks for the report! I'm going to close as this is a duplicate of #56625.

To work around the issue, you can manually adjust the paths in the strings to start with crate:: before doing the migration. Alternatively, you can migrate with the --broken-code flag, and then fix the issues manually.

@ehuss ehuss closed this as completed Jul 29, 2021
@Kixunil
Copy link
Contributor Author

Kixunil commented Jul 29, 2021

Damn, I didn't find #56625 I guess because of funny title. Yeah, --broken-code helped. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants