Skip to content

Commit 94c6160

Browse files
committed
Some cleanup in ty_to_str.
1 parent f8ac788 commit 94c6160

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/comp/util/ppaux.rs

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,64 +90,61 @@ fn ty_to_str(cx: &ctxt, typ: &t) -> str {
9090
ret mstr + ty_to_str(cx, m.ty);
9191
}
9292
alt cname(cx, typ) { some(cs) { ret cs; } _ { } }
93-
let s = "";
94-
alt struct(cx, typ) {
95-
ty_native(_) { s += "native"; }
96-
ty_nil. { s += "()"; }
97-
ty_bot. { s += "_|_"; }
98-
ty_bool. { s += "bool"; }
99-
ty_int. { s += "int"; }
100-
ty_float. { s += "float"; }
101-
ty_uint. { s += "uint"; }
102-
ty_machine(tm) { s += ty_mach_to_str(tm); }
103-
ty_char. { s += "char"; }
104-
ty_str. { s += "str"; }
105-
ty_istr. { s += "istr"; }
106-
ty_box(tm) { s += "@" + mt_to_str(cx, tm); }
107-
ty_uniq(t) { s += "~" + ty_to_str(cx, t); }
108-
ty_vec(tm) { s += "[" + mt_to_str(cx, tm) + "]"; }
109-
ty_type. { s += "type"; }
93+
ret alt struct(cx, typ) {
94+
ty_native(_) { "native" }
95+
ty_nil. { "()" }
96+
ty_bot. { "_|_" }
97+
ty_bool. { "bool" }
98+
ty_int. { "int" }
99+
ty_float. { "float" }
100+
ty_uint. { "uint" }
101+
ty_machine(tm) { ty_mach_to_str(tm) }
102+
ty_char. { "char" }
103+
ty_str. { "str" }
104+
ty_istr. { "istr" }
105+
ty_box(tm) { "@" + mt_to_str(cx, tm) }
106+
ty_uniq(t) { "~" + ty_to_str(cx, t) }
107+
ty_vec(tm) { "[" + mt_to_str(cx, tm) + "]" }
108+
ty_type. { "type" }
110109
ty_rec(elems) {
111110
let strs: [str] = ~[];
112111
for fld: field in elems { strs += ~[field_to_str(cx, fld)]; }
113-
s += "{" + str::connect(strs, ",") + "}";
112+
"{" + str::connect(strs, ",") + "}"
114113
}
115114
ty_tup(elems) {
116115
let strs = ~[];
117116
for elem in elems { strs += ~[ty_to_str(cx, elem)]; }
118-
s += "(" + str::connect(strs, ",") + ")";
117+
"(" + str::connect(strs, ",") + ")"
119118
}
120119
ty_tag(id, tps) {
121-
s += get_id_ident(cx, id);
120+
let s = get_id_ident(cx, id);
122121
if vec::len::<t>(tps) > 0u {
123122
let strs: [str] = ~[];
124123
for typ: t in tps { strs += ~[ty_to_str(cx, typ)]; }
125124
s += "[" + str::connect(strs, ",") + "]";
126125
}
126+
s
127127
}
128128
ty_fn(proto, inputs, output, cf, constrs) {
129-
s += fn_to_str(cx, proto, none, inputs, output, cf, constrs);
129+
fn_to_str(cx, proto, none, inputs, output, cf, constrs)
130130
}
131131
ty_native_fn(_, inputs, output) {
132-
s +=
133-
fn_to_str(cx, ast::proto_fn, none, inputs, output, ast::return,
134-
~[]);
132+
fn_to_str(cx, ast::proto_fn, none, inputs, output, ast::return, ~[])
135133
}
136134
ty_obj(meths) {
137135
let strs = ~[];
138136
for m: method in meths { strs += ~[method_to_str(cx, m)]; }
139-
s += "obj {\n\t" + str::connect(strs, "\n\t") + "\n}";
137+
"obj {\n\t" + str::connect(strs, "\n\t") + "\n}"
140138
}
141139
ty_res(id, _, _) {
142-
s += get_id_ident(cx, id);
140+
get_id_ident(cx, id)
143141
}
144-
ty_var(v) { s += "<T" + int::str(v) + ">"; }
142+
ty_var(v) { "<T" + int::str(v) + ">" }
145143
ty_param(id,_) {
146-
s += "'" + str::unsafe_from_bytes(~[('a' as u8) + (id as u8)]);
144+
"'" + str::unsafe_from_bytes(~[('a' as u8) + (id as u8)])
147145
}
148-
_ { s += ty_to_short_str(cx, typ); }
146+
_ { ty_to_short_str(cx, typ) }
149147
}
150-
ret s;
151148
}
152149

153150
fn ty_to_short_str(cx: &ctxt, typ: t) -> str {

0 commit comments

Comments
 (0)