-
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
Make accesses to fields of packed structs unsafe #44884
Merged
Merged
Commits on Nov 26, 2017
-
Configuration menu - View commit details
-
Copy full SHA for c48650e - Browse repository at this point
Copy the full SHA c48650eView commit details -
make accesses to fields of packed structs unsafe
To handle packed structs with destructors (which you'll think are a rare case, but the `#[repr(packed)] struct Packed<T>(T);` pattern is ever-popular, which requires handling packed structs with destructors to avoid monomorphization-time errors), drops of subfields of packed structs should drop a local move of the field instead of the original one. cc rust-lang#27060 - this should deal with that issue after codegen of drop glue is updated. The new errors need to be changed to future-compatibility warnings, but I'll rather do a crater run first with them as errors to assess the impact.
Configuration menu - View commit details
-
Copy full SHA for bdb72ed - Browse repository at this point
Copy the full SHA bdb72edView commit details -
This is required because the old version depended on tendril 0.3.1, which used `repr(packed)` incorrectly - see kuchiki-rs/kuchiki#38
Configuration menu - View commit details
-
Copy full SHA for 3801c05 - Browse repository at this point
Copy the full SHA 3801c05View commit details -
Configuration menu - View commit details
-
Copy full SHA for 06eb5a6 - Browse repository at this point
Copy the full SHA 06eb5a6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1a2d443 - Browse repository at this point
Copy the full SHA 1a2d443View commit details -
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.
Configuration menu - View commit details
-
Copy full SHA for dee8a71 - Browse repository at this point
Copy the full SHA dee8a71View commit details -
Configuration menu - View commit details
-
Copy full SHA for 617b413 - Browse repository at this point
Copy the full SHA 617b413View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7dbbbf6 - Browse repository at this point
Copy the full SHA 7dbbbf6View commit details -
There's a trailing whitespace problem in one of the tests. @nrc said he'll go fix it quickly, but until then I'll like to land this PR. I suspect this happened because one of the dependencies in the Cargo.lock I updated had changed the format of the XML they emit, but that has to be investigated.
Configuration menu - View commit details
-
Copy full SHA for 47d53e8 - Browse repository at this point
Copy the full SHA 47d53e8View commit details -
Ariel Ben-Yehuda committed
Nov 26, 2017 Configuration menu - View commit details
-
Copy full SHA for f3b2d7f - Browse repository at this point
Copy the full SHA f3b2d7fView commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.