rustc: Fix the AST map to actually map blocks. Also improve region error messages involving blocks.
This commit is contained in:
parent
389f53c6ff
commit
4ea3b0b89c
@ -55,7 +55,8 @@ fn mk_ast_map_visitor() -> vt {
|
||||
visit_fn: map_fn,
|
||||
visit_local: map_local,
|
||||
visit_arm: map_arm,
|
||||
visit_view_item: map_view_item
|
||||
visit_view_item: map_view_item,
|
||||
visit_block: map_block
|
||||
with *visit::default_visitor()
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import std::map::hashmap;
|
||||
import middle::ty;
|
||||
import middle::ty::*;
|
||||
import metadata::encoder;
|
||||
import syntax::codemap;
|
||||
import syntax::print::pprust;
|
||||
import syntax::print::pprust::{path_to_str, constr_args_to_str, proto_to_str,
|
||||
mode_to_str};
|
||||
@ -8,6 +10,24 @@ import syntax::{ast, ast_util};
|
||||
import middle::ast_map;
|
||||
import driver::session::session;
|
||||
|
||||
fn region_to_str(cx: ctxt, region: region) -> str {
|
||||
alt region {
|
||||
re_named(_) { "<name>." } // TODO: include name
|
||||
re_caller(_) { "<caller>." }
|
||||
re_block(node_id) {
|
||||
alt cx.items.get(node_id) {
|
||||
ast_map::node_block(blk) {
|
||||
#fmt("<block at %s>.", codemap::span_to_str(blk.span,
|
||||
cx.sess.codemap))
|
||||
}
|
||||
_ { cx.sess.bug("re_block refers to non-block") }
|
||||
}
|
||||
}
|
||||
re_self(_) { "self." }
|
||||
re_inferred { "" }
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) ->
|
||||
str {
|
||||
@ -68,15 +88,6 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
base
|
||||
}
|
||||
}
|
||||
fn region_to_str(_cx: ctxt, r: region) -> str {
|
||||
alt r {
|
||||
re_named(_) { "<name>." } // TODO: include name
|
||||
re_caller(_) { "<caller>." }
|
||||
re_block(_) { "<block>." } // TODO: include line number
|
||||
re_self(_) { "self." }
|
||||
re_inferred { "" }
|
||||
}
|
||||
}
|
||||
|
||||
// if there is an id, print that instead of the structural type:
|
||||
alt ty::type_def_id(typ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user