Skip to content

Commit 39ec9f8

Browse files
committed
trans: Add Type::to_string method to improve options for debug output.
1 parent 661a5ad commit 39ec9f8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/librustc_trans/trans/type_.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ impl Type {
5050
self.rf
5151
}
5252

53+
pub fn to_string(self: Type) -> String {
54+
llvm::build_string(|s| unsafe {
55+
llvm::LLVMWriteTypeToString(self.to_ref(), s);
56+
}).expect("non-UTF8 type description from LLVM")
57+
}
58+
5359
pub fn void(ccx: &CrateContext) -> Type {
5460
ty!(llvm::LLVMVoidTypeInContext(ccx.llcx()))
5561
}
@@ -315,9 +321,7 @@ impl TypeNames {
315321
}
316322

317323
pub fn type_to_string(&self, ty: Type) -> String {
318-
llvm::build_string(|s| unsafe {
319-
llvm::LLVMWriteTypeToString(ty.to_ref(), s);
320-
}).expect("non-UTF8 type description from LLVM")
324+
ty.to_string()
321325
}
322326

323327
pub fn types_to_str(&self, tys: &[Type]) -> String {

0 commit comments

Comments
 (0)