]> git.lizzy.rs Git - rust.git/commitdiff
trans: Add Type::to_string method to improve options for debug output.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Mon, 27 Jul 2015 12:40:55 +0000 (14:40 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Tue, 28 Jul 2015 18:08:29 +0000 (20:08 +0200)
src/librustc_trans/trans/type_.rs

index c88509dac4caa5ae80c621fc2487405a82ae6c18..699115a07098640a15beeb89af252fb603c2e5d3 100644 (file)
@@ -50,6 +50,12 @@ pub fn to_ref(&self) -> TypeRef {
         self.rf
     }
 
+    pub fn to_string(self: Type) -> String {
+        llvm::build_string(|s| unsafe {
+            llvm::LLVMWriteTypeToString(self.to_ref(), s);
+        }).expect("non-UTF8 type description from LLVM")
+    }
+
     pub fn void(ccx: &CrateContext) -> Type {
         ty!(llvm::LLVMVoidTypeInContext(ccx.llcx()))
     }
@@ -315,9 +321,7 @@ pub fn find_type(&self, s: &str) -> Option<Type> {
     }
 
     pub fn type_to_string(&self, ty: Type) -> String {
-        llvm::build_string(|s| unsafe {
-                llvm::LLVMWriteTypeToString(ty.to_ref(), s);
-            }).expect("non-UTF8 type description from LLVM")
+        ty.to_string()
     }
 
     pub fn types_to_str(&self, tys: &[Type]) -> String {