Skip to content

Commit 8811bfa

Browse files
committed
Add repr attributes in various places that need them.
1 parent aadeecb commit 8811bfa

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

src/libextra/enum_set.rs

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

137137
use enum_set::*;
138138

139-
#[deriving(Eq)]
139+
#[deriving(Eq)] #[repr(uint)]
140140
enum Foo {
141141
A, B, C
142142
}

src/librustc/lib/llvm.rs

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

148+
#[repr(C)]
148149
pub enum AtomicBinOp {
149150
Xchg = 0,
150151
Add = 1,
@@ -159,6 +160,7 @@ pub enum AtomicBinOp {
159160
UMin = 10,
160161
}
161162

163+
#[repr(C)]
162164
pub enum AtomicOrdering {
163165
NotAtomic = 0,
164166
Unordered = 1,
@@ -171,6 +173,7 @@ pub enum AtomicOrdering {
171173
}
172174

173175
// Consts for the LLVMCodeGenFileType type (in include/llvm/c/TargetMachine.h)
176+
#[repr(C)]
174177
pub enum FileType {
175178
AssemblyFile = 0,
176179
ObjectFile = 1
@@ -192,20 +195,23 @@ pub enum AsmDialect {
192195
}
193196

194197
#[deriving(Eq)]
198+
#[repr(C)]
195199
pub enum CodeGenOptLevel {
196200
CodeGenLevelNone = 0,
197201
CodeGenLevelLess = 1,
198202
CodeGenLevelDefault = 2,
199203
CodeGenLevelAggressive = 3,
200204
}
201205

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

214+
#[repr(C)]
209215
pub enum CodeGenModel {
210216
CodeModelDefault = 0,
211217
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
@@ -712,7 +712,7 @@ pub struct ParamBounds {
712712

713713
pub type BuiltinBounds = EnumSet<BuiltinBound>;
714714

715-
#[deriving(Clone, Eq, IterBytes, ToStr)]
715+
#[deriving(Clone, Eq, IterBytes, ToStr)] #[repr(uint)]
716716
pub enum BuiltinBound {
717717
BoundStatic,
718718
BoundSend,

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)