From bcf62e790151eda088896cd5aeda4b727ec1572a Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 29 Jul 2013 13:44:53 -0700 Subject: Make node_id_to_str print more useful info in some cases. Closes #2410. --- src/libsyntax/ast_map.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 5cba22a8e23..6b4da9671a9 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -466,11 +466,11 @@ pub fn node_id_to_str(map: map, id: NodeId, itr: @ident_interner) -> ~str { Some(&node_local(ident)) => { fmt!("local (id=%?, name=%s)", id, itr.get(ident.name)) } - Some(&node_block(_)) => { - fmt!("block") + Some(&node_block(ref block)) => { + fmt!("block %s (id=%?)", pprust::block_to_str(block, itr), id) } - Some(&node_struct_ctor(*)) => { - fmt!("struct_ctor") + Some(&node_struct_ctor(_, _, path)) => { + fmt!("struct_ctor %s (id=%?)", path_to_str(*path, itr), id) } } } -- cgit 1.4.1-3-g733a5 From a20081666becc9c48b8818a493349c20c480ef06 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Mon, 29 Jul 2013 14:19:04 -0700 Subject: Fix an unused variable warning and clean up some dead code/names. --- src/librustc/middle/trans/base.rs | 30 +++++++++++------------------- src/librustc/middle/trans/foreign.rs | 2 +- src/libsyntax/ast_util.rs | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src/libsyntax') diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0a28da5f88a..6b35f4ae9a4 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2218,23 +2218,14 @@ pub fn trans_mod(ccx: @mut CrateContext, m: &ast::_mod) { pub fn register_fn(ccx: @mut CrateContext, sp: span, sym: ~str, - node_id: ast::NodeId) - -> ValueRef { - let t = ty::node_id_to_type(ccx.tcx, node_id); - register_fn_full(ccx, sp, sym, node_id, t) -} - -pub fn register_fn_full(ccx: @mut CrateContext, - sp: span, - sym: ~str, - node_id: ast::NodeId, - node_type: ty::t) - -> ValueRef { + node_id: ast::NodeId, + node_type: ty::t) + -> ValueRef { let llfty = type_of_fn_from_ty(ccx, node_type); - register_fn_fuller(ccx, sp, sym, node_id, lib::llvm::CCallConv, llfty) + register_fn_llvmty(ccx, sp, sym, node_id, lib::llvm::CCallConv, llfty) } -pub fn register_fn_fuller(ccx: @mut CrateContext, +pub fn register_fn_llvmty(ccx: @mut CrateContext, sp: span, sym: ~str, node_id: ast::NodeId, @@ -2449,7 +2440,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { ast::item_fn(_, purity, _, _, _) => { let llfn = if purity != ast::extern_fn { - register_fn_full(ccx, i.span, sym, i.id, ty) + register_fn(ccx, i.span, sym, i.id, ty) } else { foreign::register_foreign_fn(ccx, i.span, sym, i.id) }; @@ -2499,7 +2490,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { let path = vec::append((*pth).clone(), [path_name(ni.ident)]); let sym = exported_name(ccx, path, ty, ni.attrs); - register_fn_full(ccx, ni.span, sym, ni.id, ty) + register_fn(ccx, ni.span, sym, ni.id, ty) } ast::foreign_item_static(*) => { let ident = token::ident_to_str(&ni.ident); @@ -2527,7 +2518,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { llfn = match enm.node { ast::item_enum(_, _) => { - register_fn_full(ccx, (*v).span, sym, id, ty) + register_fn(ccx, (*v).span, sym, id, ty) } _ => fail!("node_variant, shouldn't happen") }; @@ -2551,7 +2542,8 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef { let ty = ty::node_id_to_type(ccx.tcx, ctor_id); let sym = exported_name(ccx, (*struct_path).clone(), ty, struct_item.attrs); - let llfn = register_fn_full(ccx, struct_item.span, sym, ctor_id, ty); + let llfn = register_fn(ccx, struct_item.span, + sym, ctor_id, ty); set_inline_hint(llfn); llfn } @@ -2586,7 +2578,7 @@ pub fn register_method(ccx: @mut CrateContext, let sym = exported_name(ccx, path, mty, m.attrs); - let llfn = register_fn_full(ccx, m.span, sym, id, mty); + let llfn = register_fn(ccx, m.span, sym, id, mty); set_inline_hint_if_appr(m.attrs, llfn); llfn } diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 20c8e69129d..ede2292725c 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -1157,6 +1157,6 @@ pub fn register_foreign_fn(ccx: @mut CrateContext, let tys = shim_types(ccx, node_id); do tys.fn_ty.decl_fn |fnty| { - register_fn_fuller(ccx, sp, sym.take(), node_id, lib::llvm::CCallConv, fnty) + register_fn_llvmty(ccx, sp, sym.take(), node_id, lib::llvm::CCallConv, fnty) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 11d3740be3f..84e6544f780 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -410,7 +410,7 @@ impl IdVisitor { impl Visitor<()> for IdVisitor { fn visit_mod(@mut self, module: &_mod, - span: span, + _span: span, node_id: NodeId, env: ()) { (self.visit_callback)(node_id); -- cgit 1.4.1-3-g733a5