about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-10-02 15:15:23 +0200
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2017-11-26 16:12:43 +0200
commitdee8a71cd5221536c319ca8c14108e93521092f5 (patch)
tree61b09dc7938e27204cd5f6c05bda56cce7e9f356 /src/libstd
parent1a2d443f55ce05fa96f309b94ceabf4813f06045 (diff)
downloadrust-dee8a71cd5221536c319ca8c14108e93521092f5.tar.gz
rust-dee8a71cd5221536c319ca8c14108e93521092f5.zip
fix #[derive] implementation for repr(packed) structs
Fix the derive implementation for repr(packed) structs to move the
fields out instead of calling functions on references to each subfield.

That's it, `#[derive(PartialEq)]` on a packed struct now does:
```Rust
fn eq(&self, other: &Self) {
    let field_0 = self.0;
    let other_field_0 = other.0;
    &field_0 == &other_field_0
}
```

Instead of
```Rust
fn eq(&self, other: &Self) {
    let ref field_0 = self.0;
    let ref other_field_0 = other.0;
    &*field_0 == &*other_field_0
}
```

Taking (unaligned) references to each subfield is undefined, unsound and
is an error with MIR effectck, so it had to be prevented. This causes
a borrowck error when a `repr(packed)` struct has a non-Copy field (and
therefore is a [breaking-change]), but I don't see a sound way to avoid
that error.
Diffstat (limited to 'src/libstd')
0 files changed, 0 insertions, 0 deletions