Skip to content

Commit 8da718f

Browse files
committed
---
yaml --- r: 66419 b: refs/heads/master c: 050d0e6 h: refs/heads/master i: 66417: 625b163 66415: 0ea0b32 v: v3
1 parent 30afa9b commit 8da718f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 47afb33981c7f20d33e04b938c4362f4da12529a
2+
refs/heads/master: 050d0e6b29d19978584f6e389f53612497b7e41e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/librustc/lib/llvm.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,12 +2149,17 @@ impl TypeNames {
21492149
self.named_types.find_equiv(&s).map_consume(|x| Type::from_ref(*x))
21502150
}
21512151

2152-
pub fn type_to_str(&self, ty: Type) -> ~str {
2152+
// We have a depth count, because we seem to make infinite types.
2153+
pub fn type_to_str_depth(&self, ty: Type, depth: int) -> ~str {
21532154
match self.find_name(&ty) {
21542155
option::Some(name) => return name.to_owned(),
21552156
None => ()
21562157
}
21572158

2159+
if depth == 0 {
2160+
return ~"###";
2161+
}
2162+
21582163
unsafe {
21592164
let kind = ty.kind();
21602165

@@ -2176,31 +2181,36 @@ impl TypeNames {
21762181
Function => {
21772182
let out_ty = ty.return_type();
21782183
let args = ty.func_params();
2179-
let args = args.map(|&ty| self.type_to_str(ty)).connect(", ");
2180-
let out_ty = self.type_to_str(out_ty);
2184+
let args =
2185+
args.map(|&ty| self.type_to_str_depth(ty, depth-1)).connect(", ");
2186+
let out_ty = self.type_to_str_depth(out_ty, depth-1);
21812187
fmt!("fn(%s) -> %s", args, out_ty)
21822188
}
21832189
Struct => {
21842190
let tys = ty.field_types();
2185-
let tys = tys.map(|&ty| self.type_to_str(ty)).connect(", ");
2191+
let tys = tys.map(|&ty| self.type_to_str_depth(ty, depth-1)).connect(", ");
21862192
fmt!("{%s}", tys)
21872193
}
21882194
Array => {
21892195
let el_ty = ty.element_type();
2190-
let el_ty = self.type_to_str(el_ty);
2196+
let el_ty = self.type_to_str_depth(el_ty, depth-1);
21912197
let len = ty.array_length();
21922198
fmt!("[%s x %u]", el_ty, len)
21932199
}
21942200
Pointer => {
21952201
let el_ty = ty.element_type();
2196-
let el_ty = self.type_to_str(el_ty);
2202+
let el_ty = self.type_to_str_depth(el_ty, depth-1);
21972203
fmt!("*%s", el_ty)
21982204
}
21992205
_ => fail!("Unknown Type Kind (%u)", kind as uint)
22002206
}
22012207
}
22022208
}
22032209

2210+
pub fn type_to_str(&self, ty: Type) -> ~str {
2211+
self.type_to_str_depth(ty, 30)
2212+
}
2213+
22042214
pub fn val_to_str(&self, val: ValueRef) -> ~str {
22052215
unsafe {
22062216
let ty = Type::from_ref(llvm::LLVMTypeOf(val));

0 commit comments

Comments
 (0)