-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Erroneous warning about packed struct not implementing Copy #71740
Comments
Hm, the error is certainly not good. I suspect Fixing the error is a rustc bug, though. |
Yeah there exists this serde bug: #1747 |
But wait, in this issue #46043 in the issue description there is this part:
So is it supposed to be done for custom, non fundamental derives too (like serde's
|
I think each derive needs to be adjusted to handle this... but I don't actually know and did not look at the code.
Yeah, this shows that serde does not properly make a copy. |
@RalfJung This is now fixed in serde. However I still think the error message is confusing. If the warning is generated because of incorrect use of references into packed fields in the derived code, then that is what the warning message should say instead of saying that the type doesn't derive |
Agreed, the rustc diagnostic should be improved. What it says is correct for the built-in |
The original code now compiles, but we need a repro to evaluate the diagnostic. |
@nnethercote did a bunch of |
I did make changes to packed structs in #104429 but I don't think that will affect this example, which has The original error no longer occurs because of the serde fix. One way to get a reproducing test case would be to undo that change in serde. Or it might be reasonable just to close this issue given that the error message is no longer occurring in practice. |
Actually, looks like #104429 did remove that error. So I think this can be closed. |
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7d186291bfe30222d01ed0af2fa28c4c
I expected to see this happen: Compile without any warning or error.
Instead, this happened: The following warning was emitted:
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: