]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/type_.rs
Various minor/cosmetic improvements to code
[rust.git] / src / librustc_codegen_llvm / type_.rs
index 5c4ebc35240d45042031f66e9b1cdc47f3e70727..313ab1f974fdebff30c357620707ce8a33b05b3b 100644 (file)
@@ -47,6 +47,22 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+impl CodegenCx<'ll, 'tcx> {
+    crate fn type_named_struct(&self, name: &str) -> &'ll Type {
+        let name = SmallCStr::new(name);
+        unsafe {
+            llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr())
+        }
+    }
+
+    crate fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
+        unsafe {
+            llvm::LLVMStructSetBody(ty, els.as_ptr(),
+                                    els.len() as c_uint, packed as Bool)
+        }
+    }
+}
+
 impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
     fn type_void(&self) -> &'ll Type {
         unsafe {
@@ -160,13 +176,6 @@ fn type_struct(
         }
     }
 
-    fn type_named_struct(&self, name: &str) -> &'ll Type {
-        let name = SmallCStr::new(name);
-        unsafe {
-            llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr())
-        }
-    }
-
 
     fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
         unsafe {
@@ -186,13 +195,6 @@ fn type_kind(&self, ty: &'ll Type) -> TypeKind {
         }
     }
 
-    fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
-        unsafe {
-            llvm::LLVMStructSetBody(ty, els.as_ptr(),
-                                    els.len() as c_uint, packed as Bool)
-        }
-    }
-
     fn type_ptr_to(&self, ty: &'ll Type) -> &'ll Type {
         assert_ne!(self.type_kind(ty), TypeKind::Function,
                    "don't call ptr_to on function types, use ptr_to_llvm_type on FnType instead");
@@ -253,7 +255,7 @@ pub fn i8_llcx(llcx: &llvm::Context) -> &Type {
         }
     }
 
-    // Creates an integer type with the given number of bits, e.g. i24
+    // Creates an integer type with the given number of bits, e.g., i24
     pub fn ix_llcx(
         llcx: &llvm::Context,
         num_bits: u64