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

Add #[packed] attribute to create packed structs #5816

Merged
merged 2 commits into from
Apr 10, 2013

Conversation

huonw
Copy link
Member

@huonw huonw commented Apr 10, 2013

#5758 take 2.

This adds a #[packed] attribute for structs, like GCC's __attribute__((packed)), e.g.

#[packed]
struct Size5 {
   a: u8,
   b: u32
}

It works on normal and tuple structs, but is (silently) ignored on enums.

Closes #1704.

huonw added 2 commits April 10, 2013 23:39
A struct (inc. tuple struct) can be annotated with #[packed], so that there
is no padding between its elements, like GCC's `__attribute__((packed))`.

Closes rust-lang#1704
@huonw
Copy link
Member Author

huonw commented Apr 10, 2013

@nikomatsakis, how does this look? Unsurprisingly, using the existing infrastructure made the whole thing seem nicer.

I didn't bother with the cache, since it is only used in type_of and adt::represent_type, but both of these already have a cache.

@nikomatsakis
Copy link
Contributor

@dbaupp looks great.

bors added a commit that referenced this pull request Apr 10, 2013
#5758 take 2.

This adds a `#[packed]` attribute for structs, like GCC's `__attribute__((packed))`, e.g.

```rust
#[packed]
struct Size5 {
   a: u8,
   b: u32
}
```

It works on normal and tuple structs, but is (silently) ignored on enums.

Closes #1704.
@bors bors closed this Apr 10, 2013
@bors bors merged commit 7d7e149 into rust-lang:incoming Apr 10, 2013
@huonw huonw deleted the rustc-packed-v2 branch April 10, 2013 22:50
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 17, 2020
Rustup

r? @ghost

Preparation for emergency Clippyup to fix an ICE rust-lang#5816

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants