Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knocking out a quick fixme: pretty-printing exprs in error messages. #306

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import middle.ty;
import back.x86;
import back.abi;

import pretty.pprust;

import middle.ty.pat_ty;
import middle.ty.plain_ty;

Expand Down Expand Up @@ -4910,8 +4912,7 @@ fn trans_log(@block_ctxt cx, @ast.expr e) -> result {
fn trans_check_expr(@block_ctxt cx, @ast.expr e) -> result {
auto cond_res = trans_expr(cx, e);

// FIXME: need pretty-printer.
auto expr_str = "<expr>";
auto expr_str = pretty.pprust.expr_to_str(e);
auto fail_cx = new_sub_block_ctxt(cx, "fail");
auto fail_res = trans_fail(fail_cx, e.span, expr_str);

Expand Down
5 changes: 5 additions & 0 deletions src/comp/pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ impure fn print_literal(ps s, @ast.lit lit) {
wrd(s.s, common.istr(val as int));
wrd(s.s, common.ty_mach_to_str(mach));
}
case (ast.lit_mach_float(?mach,?val)) {
// val is already a str
wrd(s.s, val);
wrd(s.s, common.ty_mach_to_str(mach));
}
case (ast.lit_nil) {wrd(s.s, "()");}
case (ast.lit_bool(?val)) {
if (val) {wrd(s.s, "true");} else {wrd(s.s, "false");}
Expand Down