Skip to content

Commit a21ebb2

Browse files
committed
Fix bad argument type of pprust::print_type
AST types are boxed, there's no need for every caller to do the unboxing
1 parent 1570949 commit a21ebb2

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

src/comp/middle/tstate/ck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn check_states_against_conditions(fcx: &fn_ctxt, f: &_fn,
151151
return a value");
152152
fcx.ccx.tcx.sess.span_fatal(f.decl.output.span,
153153
"see declared return type of '" +
154-
ty_to_str(*f.decl.output) + "'");
154+
ty_to_str(f.decl.output) + "'");
155155
} else if (f.decl.cf == noreturn) {
156156
// check that this really always fails
157157
// Note that it's ok for i_diverge and i_return to both be true.

src/comp/syntax/print/pprust.rs

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn print_crate(cm: &codemap, crate: @ast::crate, filename: str,
9090
eof(s.s);
9191
}
9292

93-
fn ty_to_str(ty: &ast::ty) -> str { be to_str(ty, print_type); }
93+
fn ty_to_str(ty: &@ast::ty) -> str { be to_str(ty, print_type); }
9494

9595
fn pat_to_str(pat: &@ast::pat) -> str { be to_str(pat, print_pat); }
9696

@@ -268,9 +268,7 @@ fn print_native_mod(s: &ps, nmod: &ast::native_mod,
268268
for item: @ast::native_item in nmod.items { print_native_item(s, item); }
269269
}
270270

271-
fn print_boxed_type(s: &ps, ty: &@ast::ty) { print_type(s, *ty); }
272-
273-
fn print_type(s: &ps, ty: &ast::ty) {
271+
fn print_type(s: &ps, ty: &@ast::ty) {
274272
maybe_print_comment(s, ty.span.lo);
275273
ibox(s, 0u);
276274
alt ty.node {
@@ -293,19 +291,19 @@ fn print_type(s: &ps, ty: &ast::ty) {
293291
ast::maybe_mut. { word_space(s, "mutable?"); }
294292
ast::imm. {}
295293
}
296-
print_type(s, *mt.ty);
294+
print_type(s, mt.ty);
297295
word(s.s, "]");
298296
}
299297
ast::ty_ptr(mt) { word(s.s, "*"); print_mt(s, mt); }
300298
ast::ty_task. { word(s.s, "task"); }
301299
ast::ty_port(t) {
302300
word(s.s, "port[");
303-
print_type(s, *t);
301+
print_type(s, t);
304302
word(s.s, "]");
305303
}
306304
ast::ty_chan(t) {
307305
word(s.s, "chan[");
308-
print_type(s, *t);
306+
print_type(s, t);
309307
word(s.s, "]");
310308
}
311309
ast::ty_rec(fields) {
@@ -315,7 +313,7 @@ fn print_type(s: &ps, ty: &ast::ty) {
315313
print_mutability(s, f.node.mt.mut);
316314
word(s.s, f.node.ident);
317315
word_space(s, ":");
318-
print_type(s, *f.node.mt.ty);
316+
print_type(s, f.node.mt.ty);
319317
end(s);
320318
}
321319
fn get_span(f: &ast::ty_field) -> codemap::span { ret f.span; }
@@ -324,7 +322,7 @@ fn print_type(s: &ps, ty: &ast::ty) {
324322
}
325323
ast::ty_tup(elts) {
326324
popen(s);
327-
commasep(s, inconsistent, elts, print_boxed_type);
325+
commasep(s, inconsistent, elts, print_type);
328326
pclose(s);
329327
}
330328
ast::ty_fn(proto, inputs, output, cf, constrs) {
@@ -347,7 +345,7 @@ fn print_type(s: &ps, ty: &ast::ty) {
347345
ast::ty_path(path, _) { print_path(s, path); }
348346
ast::ty_type. { word(s.s, "type"); }
349347
ast::ty_constr(t, cs) {
350-
print_type(s, *t);
348+
print_type(s, t);
351349
space(s.s);
352350
word(s.s, ast_ty_constrs_str(cs));
353351
}
@@ -396,7 +394,7 @@ fn print_item(s: &ps, item: &@ast::item) {
396394
ast::item_const(ty, expr) {
397395
head(s, "const");
398396
word_space(s, item.ident + ":");
399-
print_type(s, *ty);
397+
print_type(s, ty);
400398
space(s.s);
401399
end(s); // end the head-ibox
402400

@@ -451,7 +449,7 @@ fn print_item(s: &ps, item: &@ast::item) {
451449

452450
space(s.s);
453451
word_space(s, "=");
454-
print_type(s, *ty);
452+
print_type(s, ty);
455453
word(s.s, ";");
456454
end(s); // end the outer ibox
457455
}
@@ -469,7 +467,7 @@ fn print_item(s: &ps, item: &@ast::item) {
469467
space(s.s);
470468
if newtype {
471469
word_space(s, "=");
472-
print_type(s, *variants.(0).node.args.(0).ty);
470+
print_type(s, variants.(0).node.args.(0).ty);
473471
word(s.s, ";");
474472
end(s);
475473
} else {
@@ -481,7 +479,7 @@ fn print_item(s: &ps, item: &@ast::item) {
481479
if ivec::len(v.node.args) > 0u {
482480
popen(s);
483481
fn print_variant_arg(s: &ps, arg: &ast::variant_arg) {
484-
print_type(s, *arg.ty);
482+
print_type(s, arg.ty);
485483
}
486484
commasep(s, consistent, v.node.args, print_variant_arg);
487485
pclose(s);
@@ -501,7 +499,7 @@ fn print_item(s: &ps, item: &@ast::item) {
501499
ibox(s, indent_unit);
502500
print_mutability(s, field.mut);
503501
word_space(s, field.ident + ":");
504-
print_type(s, *field.ty);
502+
print_type(s, field.ty);
505503
end(s);
506504
}
507505
fn get_span(f: &ast::obj_field) -> codemap::span { ret f.ty.span; }
@@ -526,7 +524,7 @@ fn print_item(s: &ps, item: &@ast::item) {
526524
print_type_params(s, tps);
527525
popen(s);
528526
word_space(s, dt.decl.inputs.(0).ident + ":");
529-
print_type(s, *dt.decl.inputs.(0).ty);
527+
print_type(s, dt.decl.inputs.(0).ty);
530528
pclose(s);
531529
space(s.s);
532530
print_block(s, dt.body);
@@ -697,7 +695,7 @@ fn print_mac(s: &ps, m: &ast::mac) {
697695
}
698696
ast::mac_embed_type(ty) {
699697
word(s.s, "#<");
700-
print_type(s, *ty);
698+
print_type(s, ty);
701699
word(s.s, ">");
702700
}
703701
ast::mac_embed_block(blk) {
@@ -803,7 +801,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
803801
print_maybe_parens(s, expr, parse::parser::as_prec);
804802
space(s.s);
805803
word_space(s, "as");
806-
print_type(s, *ty);
804+
print_type(s, ty);
807805
}
808806
ast::expr_if(test, blk, elseopt) {
809807
print_if(s, test, blk, elseopt, false);
@@ -981,7 +979,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
981979
word(s.s, "port");
982980
alt t.node {
983981
ast::ty_infer. { }
984-
_ { word(s.s, "["); print_type(s, *t); word(s.s, "]"); }
982+
_ { word(s.s, "["); print_type(s, t); word(s.s, "]"); }
985983
}
986984
popen(s);
987985
pclose(s);
@@ -1001,7 +999,7 @@ fn print_expr(s: &ps, expr: &@ast::expr) {
1001999
ibox(s, indent_unit);
10021000
print_mutability(s, field.mut);
10031001
word_space(s, field.ident + ":");
1004-
print_type(s, *field.ty);
1002+
print_type(s, field.ty);
10051003
space(s.s);
10061004
word_space(s, "=");
10071005
print_expr(s, field.expr);
@@ -1055,7 +1053,7 @@ fn print_local_decl(s: &ps, loc: &@ast::local) {
10551053
print_pat(s, loc.node.pat);
10561054
alt loc.node.ty.node {
10571055
ast::ty_infer. { }
1058-
_ { word_space(s, ":"); print_type(s, *loc.node.ty); }
1056+
_ { word_space(s, ":"); print_type(s, loc.node.ty); }
10591057
}
10601058
}
10611059

@@ -1108,7 +1106,7 @@ fn print_path(s: &ps, path: &ast::path) {
11081106
}
11091107
if ivec::len(path.node.types) > 0u {
11101108
word(s.s, "[");
1111-
commasep(s, inconsistent, path.node.types, print_boxed_type);
1109+
commasep(s, inconsistent, path.node.types, print_type);
11121110
word(s.s, "]");
11131111
}
11141112
}
@@ -1174,7 +1172,7 @@ fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl,
11741172
ibox(s, indent_unit);
11751173
word_space(s, x.ident + ":");
11761174
print_alias(s, x.mode);
1177-
print_type(s, *x.ty);
1175+
print_type(s, x.ty);
11781176
end(s);
11791177
}
11801178
commasep(s, inconsistent, decl.inputs, print_arg);
@@ -1184,7 +1182,7 @@ fn print_fn_args_and_ret(s: &ps, decl: &ast::fn_decl,
11841182
if decl.output.node != ast::ty_nil {
11851183
space_if_not_bol(s);
11861184
word_space(s, "->");
1187-
print_type(s, *decl.output);
1185+
print_type(s, decl.output);
11881186
}
11891187
}
11901188

@@ -1316,7 +1314,7 @@ fn print_mutability(s: &ps, mut: &ast::mutability) {
13161314

13171315
fn print_mt(s: &ps, mt: &ast::mt) {
13181316
print_mutability(s, mt.mut);
1319-
print_type(s, *mt.ty);
1317+
print_type(s, mt.ty);
13201318
}
13211319

13221320
fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
@@ -1329,7 +1327,7 @@ fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
13291327
popen(s);
13301328
fn print_arg(s: &ps, input: &ast::ty_arg) {
13311329
print_alias(s, input.node.mode);
1332-
print_type(s, *input.node.ty);
1330+
print_type(s, input.node.ty);
13331331
}
13341332
commasep(s, inconsistent, inputs, print_arg);
13351333
pclose(s);
@@ -1339,7 +1337,7 @@ fn print_ty_fn(s: &ps, proto: &ast::proto, id: &option::t[str],
13391337
ibox(s, indent_unit);
13401338
word_space(s, "->");
13411339
alt cf {
1342-
ast::return. { print_type(s, *output); }
1340+
ast::return. { print_type(s, output); }
13431341
ast::noreturn. { word_nbsp(s, "!"); }
13441342
}
13451343
end(s);

src/comp/util/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn log_expr(e: &ast::expr) { log print::pprust::expr_to_str(@e); }
5959

6060
fn log_expr_err(e: &ast::expr) { log_err print::pprust::expr_to_str(@e); }
6161

62-
fn log_ty_err(t: &ty) { log_err print::pprust::ty_to_str(t); }
62+
fn log_ty_err(t: &@ty) { log_err print::pprust::ty_to_str(t); }
6363

6464
fn log_pat_err(p: &@pat) { log_err print::pprust::pat_to_str(p); }
6565

0 commit comments

Comments
 (0)