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

Making unaligned_references a hard error broke derives on packed structs without warning #110645

Closed
LegionMammal978 opened this issue Apr 21, 2023 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@LegionMammal978
Copy link
Contributor

LegionMammal978 commented Apr 21, 2023

I tried this code:

#[derive(Clone)]
pub struct Foo;

#[derive(Clone)]
#[repr(packed)]
pub struct Bar(Foo);

I expected to see this happen: A deny-by-default unaligned_references lint (or similar) in Rust 1.68.2, and a hard error in Rust 1.69.0.

Instead, this happened: No lint in Rust 1.68.2, and a hard error in Rust 1.69.0:

error[E0507]: cannot move out of `self` which is behind a shared reference
 --> src/lib.rs:6:16
  |
4 | #[derive(Clone)]
  |          ----- in this derive macro expansion
5 | #[repr(packed)]
6 | pub struct Bar(Foo);
  |                ^^^ move occurs because `self.0` has type `Foo`, which does not implement the `Copy` trait
  |
  = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)

(This issue was originally reported by @UncombedCoconut, who found that the bbchallenge decider-finite-automata-reduction crate no longer compiles in 1.69.0, due to the use of derive macros on a packed struct.)

Meta

rustc --version --verbose:

rustc 1.69.0 (84c898d65 2023-04-16)
binary: rustc
commit-hash: 84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc
commit-date: 2023-04-16
host: x86_64-unknown-linux-gnu
release: 1.69.0
LLVM version: 15.0.7
@LegionMammal978 LegionMammal978 added the C-bug Category: This is a bug. label Apr 21, 2023
@LegionMammal978
Copy link
Contributor Author

LegionMammal978 commented Apr 21, 2023

Ah, it appears that this is #109744. However, the 1.69.0 relnotes do not include this breaking change: they only give the PR title of "Deriving built-in traits on packed structs works with Copy fields", and the compatibility notes only talk about the unaligned_references case which was already deny-by-default. It might be helpful to add a notice.

@Dylan-DPC Dylan-DPC added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 21, 2023
@apiraino
Copy link
Contributor

apiraino commented May 2, 2023

This is something that could be handled in the release notes (Zulip discussion).

@rustbot label -I-prioritize

@rustbot rustbot removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 2, 2023
@ChrisDenton ChrisDenton added the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 16, 2023
@Enselic
Copy link
Member

Enselic commented Jul 29, 2024

Triage: It does not seem like this was added to release notes. But at this point, no one is going to read such old release notes anyway. Let's close as won't fix. Keeping this issue open won't do any good.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2024
@Enselic Enselic removed the needs-triage-legacy Old issue that were never triaged. Remove this label once the issue has been sufficiently triaged. label Jul 29, 2024
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

6 participants