Skip to content

Commit c9919b8

Browse files
committed
---
yaml --- r: 229012 b: refs/heads/try c: d96a518 h: refs/heads/master v: v3
1 parent 0588e08 commit c9919b8

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: d4268f944714dc01fe98c6353d7a23bd9631e4c2
4+
refs/heads/try: d96a518316da8eb1ab4a7af1b8b34b1f5b00fd3f
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/other-reprs.md

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,26 @@ the FFI boundary.
2626
* DSTs, tuples, and tagged unions are not a concept in C and as such are never
2727
FFI safe.
2828

29-
* **The drop flag will still be added**
29+
* **The [drop flag][] will still be added**
3030

31-
* This is equivalent to `repr(u32)` for enums (see below)
31+
* This is equivalent to one of `repr(u\*)` (see the next section) for enums. The
32+
chosen size is the default enum size for the target platform's C ABI. Note that
33+
enum representation in C is undefined, and this may be incorrect when the C
34+
code is compiled with certain flags.
35+
36+
37+
38+
# repr(u8), repr(u16), repr(u32), repr(u64)
39+
40+
These specify the size to make a C-like enum. If the discriminant overflows the
41+
integer it has to fit in, it will be an error. You can manually ask Rust to
42+
allow this by setting the overflowing element to explicitly be 0. However Rust
43+
will not allow you to create an enum where two variants have the same discriminant.
44+
45+
On non-C-like enums, this will inhibit certain optimizations like the null-pointer
46+
optimization.
47+
48+
These reprs have no affect on a struct.
3249

3350

3451

@@ -40,22 +57,15 @@ byte. This may improve the memory footprint, but will likely have other
4057
negative side-effects.
4158

4259
In particular, most architectures *strongly* prefer values to be aligned. This
43-
may mean the unaligned loads are penalized (x86), or even fault (ARM). In
44-
particular, the compiler may have trouble with references to unaligned fields.
60+
may mean the unaligned loads are penalized (x86), or even fault (some ARM chips).
61+
For simple cases like directly loading or storing a packed field, the compiler
62+
might be able to paper over alignment issues with shifts and masks. However if
63+
you take a reference to a packed field, it's unlikely that the compiler will be
64+
able to emit code to avoid an unaligned load.
4565

4666
`repr(packed)` is not to be used lightly. Unless you have extreme requirements,
4767
this should not be used.
4868

4969
This repr is a modifier on `repr(C)` and `repr(rust)`.
5070

51-
52-
53-
54-
# repr(u8), repr(u16), repr(u32), repr(u64)
55-
56-
These specify the size to make a C-like enum. If the discriminant overflows the
57-
integer it has to fit in, it will be an error. You can manually ask Rust to
58-
allow this by setting the overflowing element to explicitly be 0. However Rust
59-
will not allow you to create an enum where two variants.
60-
61-
These reprs have no affect on a struct or non-C-like enum.
71+
[drop flag]: drop-flags.html

0 commit comments

Comments
 (0)