Skip to content

Commit c8c0876

Browse files
committed
Add repr attributes in various places that need them.
1 parent ac311ec commit c8c0876

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod test {
139139

140140
use enum_set::*;
141141

142-
#[deriving(Eq)]
142+
#[deriving(Eq)] #[repr(uint)]
143143
enum Foo {
144144
A, B, C
145145
}

src/librustc/lib/llvm.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub static Vector: TypeKind = 13;
147147
pub static Metadata: TypeKind = 14;
148148
pub static X86_MMX: TypeKind = 15;
149149

150+
#[repr(C)]
150151
pub enum AtomicBinOp {
151152
Xchg = 0,
152153
Add = 1,
@@ -161,6 +162,7 @@ pub enum AtomicBinOp {
161162
UMin = 10,
162163
}
163164

165+
#[repr(C)]
164166
pub enum AtomicOrdering {
165167
NotAtomic = 0,
166168
Unordered = 1,
@@ -173,6 +175,7 @@ pub enum AtomicOrdering {
173175
}
174176

175177
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
178+
#[repr(C)]
176179
pub enum FileType {
177180
AssemblyFile = 0,
178181
ObjectFile = 1
@@ -194,20 +197,23 @@ pub enum AsmDialect {
194197
}
195198

196199
#[deriving(Eq)]
200+
#[repr(C)]
197201
pub enum CodeGenOptLevel {
198202
CodeGenLevelNone = 0,
199203
CodeGenLevelLess = 1,
200204
CodeGenLevelDefault = 2,
201205
CodeGenLevelAggressive = 3,
202206
}
203207

208+
#[repr(C)]
204209
pub enum RelocMode {
205210
RelocDefault = 0,
206211
RelocStatic = 1,
207212
RelocPIC = 2,
208213
RelocDynamicNoPic = 3,
209214
}
210215

216+
#[repr(C)]
211217
pub enum CodeGenModel {
212218
CodeModelDefault = 0,
213219
CodeModelJITDefault = 1,

src/librustc/metadata/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub static tag_items_data_item_reexport_def_id: uint = 0x4e;
111111
pub static tag_items_data_item_reexport_name: uint = 0x4f;
112112

113113
// used to encode crate_ctxt side tables
114-
#[deriving(Eq)]
114+
#[deriving(Eq)] #[repr(uint)]
115115
pub enum astencode_tag { // Reserves 0x50 -- 0x6f
116116
tag_ast = 0x50,
117117

@@ -143,7 +143,7 @@ impl astencode_tag {
143143
pub fn from_uint(value : uint) -> Option<astencode_tag> {
144144
let is_a_tag = first_astencode_tag <= value && value <= last_astencode_tag;
145145
if !is_a_tag { None } else {
146-
Some(unsafe { cast::transmute(value as int) })
146+
Some(unsafe { cast::transmute(value) })
147147
}
148148
}
149149
}

src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ pub struct ParamBounds {
715715

716716
pub type BuiltinBounds = EnumSet<BuiltinBound>;
717717

718-
#[deriving(Clone, Eq, IterBytes, ToStr)]
718+
#[deriving(Clone, Eq, IterBytes, ToStr)] #[repr(uint)]
719719
pub enum BuiltinBound {
720720
BoundStatic,
721721
BoundSend,

src/libstd/rt/io/signal.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use result::{Err, Ok};
2626
use rt::io::io_error;
2727
use rt::rtio::{IoFactory, RtioSignal, with_local_io};
2828

29+
#[repr(int)]
2930
#[deriving(Eq, IterBytes)]
3031
pub enum Signum {
3132
/// Equivalent to SIGBREAK, delivered when the user presses Ctrl-Break.

src/test/run-pass/issue-2718.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub mod pipes {
2626
payload: Option<T>
2727
}
2828

29-
#[deriving(Eq)]
29+
#[deriving(Eq)] #[repr(int)]
3030
pub enum state {
3131
empty,
3232
full,

0 commit comments

Comments
 (0)