diff options
| author | Luqman Aden <laden@csclub.uwaterloo.ca> | 2014-10-15 02:25:34 -0400 |
|---|---|---|
| committer | Luqman Aden <laden@csclub.uwaterloo.ca> | 2014-10-16 11:15:34 -0400 |
| commit | 814586be57b87a32414b4e3fecc150686513b80f (patch) | |
| tree | 5d16d22743d333ae2f0cf4d1bd02b986d934d1f8 | |
| parent | 26e547af5d2d98c9e85770ac53217ad0f8b24999 (diff) | |
librustc: Remove all uses of {:?}.
68 files changed, 386 insertions, 341 deletions
diff --git a/src/librustc/driver/pretty.rs b/src/librustc/driver/pretty.rs index 9b6d6d4620d..75171af7411 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -518,7 +518,7 @@ pub fn pretty_print_input(sess: Session, } None => { let message = format!("--pretty=flowgraph needs \ - block, fn, or method; got {:?}", + block, fn, or method; got {}", node); // point to what was found, if there's an @@ -542,7 +542,6 @@ fn print_flowgraph<W:io::Writer>(variants: Vec<borrowck_dot::Variant>, blocks::BlockCode(block) => cfg::CFG::new(ty_cx, &*block), blocks::FnLikeCode(fn_like) => cfg::CFG::new(ty_cx, &*fn_like.body()), }; - debug!("cfg: {:?}", cfg); match code { _ if variants.len() == 0 => { diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index f0ec5beec46..b7bd97e0219 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -226,13 +226,13 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId, let class_doc = expect(tcx.sess.diagnostic(), decoder::maybe_find_item(class_id.node, all_items), || { - (format!("get_field_type: class ID {:?} not found", + (format!("get_field_type: class ID {} not found", class_id)).to_string() }); let the_field = expect(tcx.sess.diagnostic(), decoder::maybe_find_item(def.node, class_doc), || { - (format!("get_field_type: in class {:?}, field ID {:?} not found", + (format!("get_field_type: in class {}, field ID {} not found", class_id, def)).to_string() }); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 009a06f5290..b9135e974c5 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -256,7 +256,7 @@ fn encode_symbol(ecx: &EncodeContext, rbml_w.start_tag(tag_items_data_item_symbol); match ecx.item_symbols.borrow().find(&id) { Some(x) => { - debug!("encode_symbol(id={:?}, str={})", id, *x); + debug!("encode_symbol(id={}, str={})", id, *x); rbml_w.writer.write(x.as_bytes()); } None => { @@ -308,7 +308,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext, id: NodeId, variants: &[P<Variant>], index: &mut Vec<entry<i64>>) { - debug!("encode_enum_variant_info(id={:?})", id); + debug!("encode_enum_variant_info(id={})", id); let mut disr_val = 0; let mut i = 0; @@ -592,7 +592,7 @@ fn encode_info_for_mod(ecx: &EncodeContext, ItemImpl(..) => { let (ident, did) = (item.ident, item.id); debug!("(encoding info for module) ... encoding impl {} \ - ({:?}/{:?})", + ({}/{})", token::get_ident(ident), did, ecx.tcx.map.node_to_string(did)); @@ -853,7 +853,7 @@ fn encode_info_for_method(ecx: &EncodeContext, parent_id: NodeId, ast_item_opt: Option<&ImplItem>) { - debug!("encode_info_for_method: {:?} {}", m.def_id, + debug!("encode_info_for_method: {} {}", m.def_id, token::get_ident(m.ident)); rbml_w.start_tag(tag_items_data_item); diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 553ec096521..34aa9310ef2 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -39,7 +39,7 @@ impl<'a> FileSearch<'a> { let mut visited_dirs = HashSet::new(); let mut found = false; - debug!("filesearch: searching additional lib search paths [{:?}]", + debug!("filesearch: searching additional lib search paths [{}]", self.addl_lib_search_paths.borrow().len()); for path in self.addl_lib_search_paths.borrow().iter() { match f(path) { @@ -66,7 +66,7 @@ impl<'a> FileSearch<'a> { for path in rustpath.iter() { let tlib_path = make_rustpkg_lib_path( self.sysroot, path, self.triple); - debug!("is {} in visited_dirs? {:?}", tlib_path.display(), + debug!("is {} in visited_dirs? {}", tlib_path.display(), visited_dirs.contains_equiv(&tlib_path.as_vec().to_vec())); if !visited_dirs.contains_equiv(&tlib_path.as_vec()) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index a07518cf3f2..c8d56c61d2b 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -43,6 +43,7 @@ use syntax::parse::token; // def-id will depend on where it originated from. Therefore, the conversion // function is given an indicator of the source of the def-id. See // astencode.rs for more information. +#[deriving(Show)] pub enum DefIdSource { // Identifies a struct, trait, enum, etc. NominalType, @@ -390,7 +391,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { } 'p' => { let did = parse_def(st, TypeParameter, |x,y| conv(x,y)); - debug!("parsed ty_param: did={:?}", did); + debug!("parsed ty_param: did={}", did); let index = parse_uint(st); assert_eq!(next(st), '|'); let space = parse_param_space(st); @@ -603,12 +604,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as ast::CrateNum, - None => fail!("internal error: parse_def_id: crate number expected, found {:?}", + None => fail!("internal error: parse_def_id: crate number expected, found {}", crate_part) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as ast::NodeId, - None => fail!("internal error: parse_def_id: id expected, found {:?}", + None => fail!("internal error: parse_def_id: id expected, found {}", def_part) }; ast::DefId { krate: crate_num, node: def_num } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 7cadcb745ca..ec693679b15 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1807,7 +1807,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did), TypeParameter => dcx.tr_intern_def_id(did) }; - debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r); + debug!("convert_def_id(source={}, did={})={}", source, did, r); return r; } } @@ -1841,7 +1841,7 @@ fn decode_side_tables(dcx: &DecodeContext, } c::tag_table_node_type => { let ty = val_dsr.read_ty(dcx); - debug!("inserting ty for node {:?}: {}", + debug!("inserting ty for node {}: {}", id, ty_to_string(dcx.tcx, ty)); dcx.tcx.node_types.borrow_mut().insert(id as uint, ty); } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index df18ec30f0e..4eba46b469c 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -119,7 +119,7 @@ impl<'a, 'tcx> euv::Delegate for CheckLoanCtxt<'a, 'tcx> { loan_cause: euv::LoanCause) { debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \ - bk={}, loan_cause={:?})", + bk={}, loan_cause={})", borrow_id, cmt.repr(self.tcx()), loan_region, bk, loan_cause); @@ -185,7 +185,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, all_loans: &[Loan], decl: &ast::FnDecl, body: &ast::Block) { - debug!("check_loans(body id={:?})", body.id); + debug!("check_loans(body id={})", body.id); let mut clcx = CheckLoanCtxt { bccx: bccx, @@ -336,10 +336,10 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! issued when we enter `scope_id` (for example, we do not //! permit two `&mut` borrows of the same variable). - debug!("check_for_conflicting_loans(scope_id={:?})", scope_id); + debug!("check_for_conflicting_loans(scope_id={})", scope_id); let new_loan_indices = self.loans_generated_by(scope_id); - debug!("new_loan_indices = {:?}", new_loan_indices); + debug!("new_loan_indices = {}", new_loan_indices); self.each_issued_loan(scope_id, |issued_loan| { for &new_loan_index in new_loan_indices.iter() { @@ -651,7 +651,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { use_path: &LoanPath, borrow_kind: ty::BorrowKind) -> UseError { - debug!("analyze_restrictions_on_use(expr_id={:?}, use_path={})", + debug!("analyze_restrictions_on_use(expr_id={}, use_path={})", self.tcx().map.node_to_string(expr_id), use_path.repr(self.tcx())); @@ -679,7 +679,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { * is using a moved/uninitialized value */ - debug!("check_if_path_is_moved(id={:?}, use_kind={:?}, lp={})", + debug!("check_if_path_is_moved(id={}, use_kind={}, lp={})", id, use_kind, lp.repr(self.bccx.tcx)); let base_lp = owned_ptr_base_path_rc(lp); self.move_data.each_move_of(id, &base_lp, |the_move, moved_lp| { diff --git a/src/librustc/middle/borrowck/gather_loans/mod.rs b/src/librustc/middle/borrowck/gather_loans/mod.rs index f2ff104ba1d..d28baf48ddc 100644 --- a/src/librustc/middle/borrowck/gather_loans/mod.rs +++ b/src/librustc/middle/borrowck/gather_loans/mod.rs @@ -112,7 +112,7 @@ impl<'a, 'tcx> euv::Delegate for GatherLoanCtxt<'a, 'tcx> { loan_cause: euv::LoanCause) { debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \ - bk={}, loan_cause={:?})", + bk={}, loan_cause={})", borrow_id, cmt.repr(self.tcx()), loan_region, bk, loan_cause); @@ -218,8 +218,8 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { * dynamically that they are not freed. */ - debug!("guarantee_valid(borrow_id={:?}, cmt={}, \ - req_mutbl={:?}, loan_region={:?})", + debug!("guarantee_valid(borrow_id={}, cmt={}, \ + req_mutbl={}, loan_region={})", borrow_id, cmt.repr(self.tcx()), req_kind, @@ -257,7 +257,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { self.bccx, borrow_span, cause, cmt.clone(), loan_region); - debug!("guarantee_valid(): restrictions={:?}", restr); + debug!("guarantee_valid(): restrictions={}", restr); // Create the loan record (if needed). let loan = match restr { @@ -289,17 +289,17 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { ty::ReInfer(..) => { self.tcx().sess.span_bug( cmt.span, - format!("invalid borrow lifetime: {:?}", + format!("invalid borrow lifetime: {}", loan_region).as_slice()); } }; - debug!("loan_scope = {:?}", loan_scope); + debug!("loan_scope = {}", loan_scope); let gen_scope = self.compute_gen_scope(borrow_id, loan_scope); - debug!("gen_scope = {:?}", gen_scope); + debug!("gen_scope = {}", gen_scope); let kill_scope = self.compute_kill_scope(loan_scope, &*loan_path); - debug!("kill_scope = {:?}", kill_scope); + debug!("kill_scope = {}", kill_scope); if req_kind == ty::MutBorrow { self.mark_loan_path_as_mutated(&*loan_path); @@ -318,7 +318,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { } }; - debug!("guarantee_valid(borrow_id={:?}), loan={}", + debug!("guarantee_valid(borrow_id={}), loan={}", borrow_id, loan.repr(self.tcx())); // let loan_path = loan.loan_path; diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index f30a370d068..bf1b4b7e476 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -21,6 +21,7 @@ use util::ppaux::Repr; use std::rc::Rc; +#[deriving(Show)] pub enum RestrictionResult { Safe, SafeIf(Rc<LoanPath>, Vec<Rc<LoanPath>>) diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index 7d0d99443b0..ec09e9e72d7 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -264,14 +264,14 @@ impl Loan { } } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum LoanPath { LpVar(ast::NodeId), // `x` in doc.rs LpUpvar(ty::UpvarId), // `x` captured by-value into closure LpExtend(Rc<LoanPath>, mc::MutabilityCategory, LoanPathElem) } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum LoanPathElem { LpDeref(mc::PointerKind), // `*LV` in doc.rs LpInterior(mc::InteriorKind) // `LV.f` in doc.rs @@ -421,6 +421,7 @@ pub enum AliasableViolationKind { BorrowViolation(euv::LoanCause) } +#[deriving(Show)] pub enum MovedValueUseKind { MovedInUse, MovedInCapture, @@ -530,8 +531,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { (ty::expr_ty_adjusted(self.tcx, &*expr), expr.span) } r => { - self.tcx.sess.bug(format!("MoveExpr({:?}) maps to \ - {:?}, not Expr", + self.tcx.sess.bug(format!("MoveExpr({}) maps to \ + {}, not Expr", the_move.id, r).as_slice()) } @@ -566,8 +567,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { (ty::expr_ty_adjusted(self.tcx, &*expr), expr.span) } r => { - self.tcx.sess.bug(format!("Captured({:?}) maps to \ - {:?}, not Expr", + self.tcx.sess.bug(format!("Captured({}) maps to \ + {}, not Expr", the_move.id, r).as_slice()) } @@ -892,7 +893,7 @@ impl DataFlowOperator for LoanDataFlowOperator { impl Repr for Loan { fn repr(&self, tcx: &ty::ctxt) -> String { - format!("Loan_{:?}({}, {:?}, {:?}-{:?}, {})", + format!("Loan_{}({}, {}, {}-{}, {})", self.index, self.loan_path.repr(tcx), self.kind, diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index eda14541961..4c2ee9fe551 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -68,7 +68,7 @@ pub struct FlowedMoveData<'a, 'tcx: 'a> { } /// Index into `MoveData.paths`, used like a pointer -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub struct MovePathIndex(uint); impl MovePathIndex { @@ -120,7 +120,7 @@ pub struct MovePath { pub next_sibling: MovePathIndex, } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum MoveKind { Declared, // When declared, variables start out "moved". MoveExpr, // Expression or binding that moves a variable @@ -284,7 +284,7 @@ impl MoveData { } }; - debug!("move_path(lp={}, index={:?})", + debug!("move_path(lp={}, index={})", lp.repr(tcx), index); @@ -341,7 +341,7 @@ impl MoveData { * location `id` with kind `kind`. */ - debug!("add_move(lp={}, id={:?}, kind={:?})", + debug!("add_move(lp={}, id={}, kind={})", lp.repr(tcx), id, kind); @@ -372,7 +372,7 @@ impl MoveData { * location `id` with the given `span`. */ - debug!("add_assignment(lp={}, assign_id={:?}, assignee_id={:?}", + debug!("add_assignment(lp={}, assign_id={}, assignee_id={}", lp.repr(tcx), assign_id, assignee_id); let path_index = self.move_path(tcx, lp.clone()); @@ -391,12 +391,12 @@ impl MoveData { }; if self.is_var_path(path_index) { - debug!("add_assignment[var](lp={}, assignment={}, path_index={:?})", + debug!("add_assignment[var](lp={}, assignment={}, path_index={})", lp.repr(tcx), self.var_assignments.borrow().len(), path_index); self.var_assignments.borrow_mut().push(assignment); } else { - debug!("add_assignment[path](lp={}, path_index={:?})", + debug!("add_assignment[path](lp={}, path_index={})", lp.repr(tcx), path_index); self.path_assignments.borrow_mut().push(assignment); diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index b573c4e5948..fa5a6a2e54a 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -483,12 +483,12 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { let inputs = inline_asm.inputs.iter(); let outputs = inline_asm.outputs.iter(); let post_inputs = self.exprs(inputs.map(|a| { - debug!("cfg::construct InlineAsm id:{} input:{:?}", expr.id, a); + debug!("cfg::construct InlineAsm id:{} input:{}", expr.id, a); let &(_, ref expr) = a; &**expr }), pred); let post_outputs = self.exprs(outputs.map(|a| { - debug!("cfg::construct InlineAsm id:{} output:{:?}", expr.id, a); + debug!("cfg::construct InlineAsm id:{} output:{}", expr.id, a); let &(_, ref expr, _) = a; &**expr }), post_inputs); @@ -616,14 +616,14 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } self.tcx.sess.span_bug( expr.span, - format!("no loop scope for id {:?}", + format!("no loop scope for id {}", loop_id).as_slice()); } r => { self.tcx.sess.span_bug( expr.span, - format!("bad entry `{:?}` in def_map for label", + format!("bad entry `{}` in def_map for label", r).as_slice()); } } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index f0455db6e3b..d6b9bbded4f 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -145,7 +145,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) -> bool { Some(&DefStruct(_)) => { } Some(&def) => { - debug!("(checking const) found bad def: {:?}", def); + debug!("(checking const) found bad def: {}", def); span_err!(v.tcx.sess, e.span, E0014, "paths in constants may only refer to constants \ or functions"); diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 3f725b86420..abccc7623a7 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -987,7 +987,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt, cx.tcx.sess.span_bug( p.span, format!("binding pattern {} is not an \ - identifier: {:?}", + identifier: {}", p.id, p.node).as_slice()); } diff --git a/src/librustc/middle/check_rvalues.rs b/src/librustc/middle/check_rvalues.rs index 2a2655cc49c..cd7c4b15494 100644 --- a/src/librustc/middle/check_rvalues.rs +++ b/src/librustc/middle/check_rvalues.rs @@ -51,7 +51,7 @@ impl<'a, 'tcx> euv::Delegate for RvalueContext<'a, 'tcx> { span: Span, cmt: mc::cmt, _: euv::ConsumeMode) { - debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty)); + debug!("consume; cmt: {}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty)); if !ty::type_is_sized(self.tcx, cmt.ty) { span_err!(self.tcx.sess, span, E0161, "cannot move a value of type {0}: the size of {0} cannot be statically determined", diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index cc1789ec642..a8b8eb2e339 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -193,8 +193,8 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let words_per_id = (bits_per_id + uint::BITS - 1) / uint::BITS; let num_nodes = cfg.graph.all_nodes().len(); - debug!("DataFlowContext::new(analysis_name: {:s}, id_range={:?}, \ - bits_per_id={:?}, words_per_id={:?}) \ + debug!("DataFlowContext::new(analysis_name: {:s}, id_range={}, \ + bits_per_id={}, words_per_id={}) \ num_nodes: {}", analysis_name, id_range, bits_per_id, words_per_id, num_nodes); @@ -222,7 +222,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { pub fn add_gen(&mut self, id: ast::NodeId, bit: uint) { //! Indicates that `id` generates `bit` - debug!("{:s} add_gen(id={:?}, bit={:?})", + debug!("{:s} add_gen(id={}, bit={})", self.analysis_name, id, bit); assert!(self.nodeid_to_index.contains_key(&id)); assert!(self.bits_per_id > 0); @@ -235,7 +235,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { pub fn add_kill(&mut self, id: ast::NodeId, bit: uint) { //! Indicates that `id` kills `bit` - debug!("{:s} add_kill(id={:?}, bit={:?})", + debug!("{:s} add_kill(id={}, bit={})", self.analysis_name, id, bit); assert!(self.nodeid_to_index.contains_key(&id)); assert!(self.bits_per_id > 0); @@ -336,7 +336,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let cfgidx = to_cfgidx_or_die(id, &self.nodeid_to_index); let (start, end) = self.compute_id_range(cfgidx); let gens = self.gens.slice(start, end); - debug!("{:s} each_gen_bit(id={:?}, gens={})", + debug!("{:s} each_gen_bit(id={}, gens={})", self.analysis_name, id, bits_to_string(gens)); self.each_bit(gens, f) } @@ -408,7 +408,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { } None => { debug!("{:s} add_kills_from_flow_exits flow_exit={} \ - no cfg_idx for exiting_scope={:?}", + no cfg_idx for exiting_scope={}", self.analysis_name, flow_exit, node_id); } } @@ -529,7 +529,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { bitwise(on_entry, pred_bits, &self.dfcx.oper) }; if changed { - debug!("{:s} changed entry set for {:?} to {}", + debug!("{:s} changed entry set for {} to {}", self.dfcx.analysis_name, cfgidx, bits_to_string(self.dfcx.on_entry.slice(start, end))); self.changed = true; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index b492203b352..bde868cdf6d 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -55,7 +55,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> { } UnsafeBlock(block_id) => { // OK, but record this. - debug!("effect: recording unsafe block as used: {:?}", block_id); + debug!("effect: recording unsafe block as used: {}", block_id); self.tcx.used_unsafe.borrow_mut().insert(block_id); } UnsafeFn => {} diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 6f179e0624f..65633cfb34c 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -73,7 +73,7 @@ pub trait Delegate { mode: MutateMode); } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum LoanCause { ClosureCapture(Span), AddrOf, @@ -85,7 +85,7 @@ pub enum LoanCause { MatchDiscriminant } -#[deriving(PartialEq,Show)] +#[deriving(PartialEq, Show)] pub enum ConsumeMode { Copy, // reference to x where x has a type that copies Move(MoveReason), // reference to x where x has a type that moves @@ -625,7 +625,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> { * meaning either copied or moved depending on its type. */ - debug!("walk_block(blk.id={:?})", blk.id); + debug!("walk_block(blk.id={})", blk.id); for stmt in blk.stmts.iter() { self.walk_stmt(&**stmt); diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 8484ec92934..463eaa40ae0 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -36,6 +36,7 @@ be indexed by the direction (see the type `Direction`). #![allow(dead_code)] // still WIP +use std::fmt::{Formatter, FormatError, Show}; use std::uint; pub struct Graph<N,E> { @@ -55,12 +56,20 @@ pub struct Edge<E> { pub data: E, } +impl<E: Show> Show for Edge<E> { + fn fmt(&self, f: &mut Formatter) -> Result<(), FormatError> { + write!(f, "Edge {{ next_edge: [{}, {}], source: {}, target: {}, data: {} }}", + self.next_edge[0], self.next_edge[1], self.source, + self.target, self.data) + } +} + #[deriving(Clone, PartialEq, Show)] pub struct NodeIndex(pub uint); #[allow(non_uppercase_statics)] pub const InvalidNodeIndex: NodeIndex = NodeIndex(uint::MAX); -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub struct EdgeIndex(pub uint); #[allow(non_uppercase_statics)] pub const InvalidEdgeIndex: EdgeIndex = EdgeIndex(uint::MAX); @@ -307,6 +316,7 @@ impl<E> Edge<E> { #[cfg(test)] mod test { use middle::graph::*; + use std::fmt::Show; type TestNode = Node<&'static str>; type TestEdge = Edge<&'static str>; @@ -361,7 +371,7 @@ mod test { }); } - fn test_adjacent_edges<N:PartialEq,E:PartialEq>(graph: &Graph<N,E>, + fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>, start_index: NodeIndex, start_data: N, expected_incoming: &[(E,N)], @@ -372,7 +382,7 @@ mod test { graph.each_incoming_edge(start_index, |edge_index, edge| { assert!(graph.edge_data(edge_index) == &edge.data); assert!(counter < expected_incoming.len()); - debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", + debug!("counter={} expected={} edge_index={} edge={}", counter, expected_incoming[counter], edge_index, edge); match expected_incoming[counter] { (ref e, ref n) => { @@ -390,7 +400,7 @@ mod test { graph.each_outgoing_edge(start_index, |edge_index, edge| { assert!(graph.edge_data(edge_index) == &edge.data); assert!(counter < expected_outgoing.len()); - debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}", + debug!("counter={} expected={} edge_index={} edge={}", counter, expected_outgoing[counter], edge_index, edge); match expected_outgoing[counter] { (ref e, ref n) => { diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index ac9df359770..490e49d051e 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -154,7 +154,7 @@ impl Clone for LiveNode { } } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] enum LiveNodeKind { FreeVarNode(Span), ExprNode(Span), @@ -240,11 +240,13 @@ struct CaptureInfo { var_nid: NodeId } +#[deriving(Show)] struct LocalInfo { id: NodeId, ident: Ident } +#[deriving(Show)] enum VarKind { Arg(NodeId, Ident), Local(LocalInfo), @@ -307,7 +309,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { ImplicitRet => {} } - debug!("{} is {:?}", v.to_string(), vk); + debug!("{} is {}", v.to_string(), vk); v } @@ -424,7 +426,7 @@ fn visit_local(ir: &mut IrMaps, local: &ast::Local) { fn visit_arm(ir: &mut IrMaps, arm: &Arm) { for pat in arm.pats.iter() { pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { - debug!("adding local variable {} from match with bm {:?}", + debug!("adding local variable {} from match with bm {}", p_id, bm); let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); @@ -442,7 +444,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { // live nodes required for uses or definitions of variables: ExprPath(_) => { let def = ir.tcx.def_map.borrow().get_copy(&expr.id); - debug!("expr {}: path that leads to {:?}", expr.id, def); + debug!("expr {}: path that leads to {}", expr.id, def); match def { DefLocal(..) => ir.add_live_node_for_node(expr.id, ExprNode(expr.span)), _ => {} @@ -489,7 +491,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) { } ExprForLoop(ref pat, _, _, _) => { pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| { - debug!("adding local variable {} from for loop with bm {:?}", + debug!("adding local variable {} from for loop with bm {}", p_id, bm); let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); @@ -733,7 +735,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let mut wr = io::MemWriter::new(); { let wr = &mut wr as &mut io::Writer; - write!(wr, "[ln({}) of kind {:?} reads", ln.get(), self.ir.lnk(ln)); + write!(wr, "[ln({}) of kind {} reads", ln.get(), self.ir.lnk(ln)); self.write_vars(wr, ln, |idx| self.users.get(idx).reader); write!(wr, " writes"); self.write_vars(wr, ln, |idx| self.users.get(idx).writer); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 4a1c4aaa895..c5993dcb39d 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -78,7 +78,7 @@ use syntax::parse::token; use std::cell::RefCell; use std::rc::Rc; -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum categorization { cat_rvalue(ty::Region), // temporary val, argument is its scope cat_static_item, @@ -94,7 +94,7 @@ pub enum categorization { // (*1) downcast is only required if the enum has more than one variant } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum CopiedUpvarKind { Boxed(ast::Onceness), Unboxed(ty::UnboxedClosureKind) @@ -111,7 +111,7 @@ impl CopiedUpvarKind { } } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub struct CopiedUpvar { pub upvar_id: ast::NodeId, pub kind: CopiedUpvarKind, @@ -119,7 +119,7 @@ pub struct CopiedUpvar { } // different kinds of pointers: -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum PointerKind { OwnedPtr, BorrowedPtr(ty::BorrowKind, ty::Region), @@ -129,19 +129,19 @@ pub enum PointerKind { // We use the term "interior" to mean "something reachable from the // base without a pointer dereference", e.g. a field -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum InteriorKind { InteriorField(FieldName), InteriorElement(ElementKind), } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum FieldName { NamedField(ast::Name), PositionalField(uint) } -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub enum ElementKind { VecElement, OtherElement, @@ -168,7 +168,7 @@ pub enum MutabilityCategory { // dereference, but its type is the type *before* the dereference // (`@T`). So use `cmt.ty` to find the type of the value in a consistent // fashion. For more details, see the method `cat_pattern` -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub struct cmt_ { pub id: ast::NodeId, // id of expr/pat producing this value pub span: Span, // span of same expr/pat @@ -542,7 +542,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { expr_ty: ty::t, def: def::Def) -> McResult<cmt> { - debug!("cat_def: id={} expr={} def={:?}", + debug!("cat_def: id={} expr={} def={}", id, expr_ty.repr(self.tcx()), def); match def { @@ -781,7 +781,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { }; let method_ty = self.typer.node_method_ty(method_call); - debug!("cat_deref: method_call={:?} method_ty={}", + debug!("cat_deref: method_call={} method_ty={}", method_call, method_ty.map(|ty| ty.repr(self.tcx()))); let base_cmt = match method_ty { @@ -1352,7 +1352,7 @@ impl cmt_ { impl Repr for cmt_ { fn repr(&self, tcx: &ty::ctxt) -> String { - format!("{{{} id:{} m:{:?} ty:{}}}", + format!("{{{} id:{} m:{} ty:{}}}", self.cat.repr(tcx), self.id, self.mutbl, @@ -1368,7 +1368,7 @@ impl Repr for categorization { cat_copied_upvar(..) | cat_local(..) | cat_upvar(..) => { - format!("{:?}", *self) + format!("{}", *self) } cat_deref(ref cmt, derefs, ptr) => { format!("{}-{}{}->", cmt.cat.repr(tcx), ptr_sigil(ptr), derefs) @@ -1405,7 +1405,7 @@ impl Repr for InteriorKind { InteriorField(NamedField(fld)) => { token::get_name(fld).get().to_string() } - InteriorField(PositionalField(i)) => format!("#{:?}", i), + InteriorField(PositionalField(i)) => format!("#{}", i), InteriorElement(_) => "[]".to_string(), } } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 8b9207134ea..6e430760e36 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -347,7 +347,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { // This code is here instead of in visit_item so that the // crate module gets processed as well. if self.prev_exported { - assert!(self.exp_map2.contains_key(&id), "wut {:?}", id); + assert!(self.exp_map2.contains_key(&id), "wut {}", id); for export in self.exp_map2.get(&id).iter() { if is_local(export.def_id) { self.reexports.insert(export.def_id.node); @@ -394,28 +394,28 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { fn def_privacy(&self, did: ast::DefId) -> PrivacyResult { if !is_local(did) { if self.external_exports.contains(&did) { - debug!("privacy - {:?} was externally exported", did); + debug!("privacy - {} was externally exported", did); return Allowable; } - debug!("privacy - is {:?} a public method", did); + debug!("privacy - is {} a public method", did); return match self.tcx.impl_or_trait_items.borrow().find(&did) { Some(&ty::MethodTraitItem(ref meth)) => { - debug!("privacy - well at least it's a method: {:?}", + debug!("privacy - well at least it's a method: {}", *meth); match meth.container { ty::TraitContainer(id) => { - debug!("privacy - recursing on trait {:?}", id); + debug!("privacy - recursing on trait {}", id); self.def_privacy(id) } ty::ImplContainer(id) => { match ty::impl_trait_ref(self.tcx, id) { Some(t) => { - debug!("privacy - impl of trait {:?}", id); + debug!("privacy - impl of trait {}", id); self.def_privacy(t.def_id) } None => { - debug!("privacy - found a method {:?}", + debug!("privacy - found a method {}", meth.vis); if meth.vis == ast::Public { Allowable @@ -430,17 +430,17 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { Some(&ty::TypeTraitItem(ref typedef)) => { match typedef.container { ty::TraitContainer(id) => { - debug!("privacy - recursing on trait {:?}", id); + debug!("privacy - recursing on trait {}", id); self.def_privacy(id) } ty::ImplContainer(id) => { match ty::impl_trait_ref(self.tcx, id) { Some(t) => { - debug!("privacy - impl of trait {:?}", id); + debug!("privacy - impl of trait {}", id); self.def_privacy(t.def_id) } None => { - debug!("privacy - found a typedef {:?}", + debug!("privacy - found a typedef {}", typedef.vis); if typedef.vis == ast::Public { Allowable @@ -551,7 +551,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { // members, so that's why we test the parent, and not the did itself. let mut cur = self.curitem; loop { - debug!("privacy - questioning {}, {:?}", self.nodestr(cur), cur); + debug!("privacy - questioning {}, {}", self.nodestr(cur), cur); match cur { // If the relevant parent is in our history, then we're allowed // to look inside any of our ancestor's immediate private items, diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 4f81aac5eb0..cf48e1899d1 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -113,7 +113,7 @@ impl RegionMaps { None => {} } - debug!("relate_free_regions(sub={:?}, sup={:?})", sub, sup); + debug!("relate_free_regions(sub={}, sup={})", sub, sup); self.free_region_map.borrow_mut().insert(sub, vec!(sup)); } @@ -211,7 +211,7 @@ impl RegionMaps { //! Returns the lifetime of the variable `id`. let scope = ty::ReScope(self.var_scope(id)); - debug!("var_region({}) = {:?}", id, scope); + debug!("var_region({}) = {}", id, scope); scope } @@ -270,7 +270,7 @@ impl RegionMaps { * duplicated with the code in infer.rs. */ - debug!("is_subregion_of(sub_region={:?}, super_region={:?})", + debug!("is_subregion_of(sub_region={}, super_region={})", sub_region, super_region); sub_region == super_region || { @@ -802,7 +802,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor, sp: Span, id: ast::NodeId) { debug!("region::resolve_fn(id={}, \ - span={:?}, \ + span={}, \ body.id={}, \ cx.parent={})", id, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index a53cd52ca84..0aff56ba3cf 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -94,6 +94,7 @@ pub type ExternalExports = DefIdSet; // FIXME: dox pub type LastPrivateMap = NodeMap<LastPrivate>; +#[deriving(Show)] pub enum LastPrivate { LastMod(PrivateDep), // `use` directives (imports) can refer to two separate definitions in the @@ -107,13 +108,14 @@ pub enum LastPrivate { pub type_used: ImportUse}, } +#[deriving(Show)] pub enum PrivateDep { AllPublic, DependsOn(DefId), } // How an import is used. -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum ImportUse { Unused, // The import is not used. Used, // The import is used. @@ -135,7 +137,7 @@ enum PatternBindingMode { ArgumentIrrefutableMode, } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] enum Namespace { TypeNS, ValueNS @@ -576,7 +578,7 @@ struct TypeNsDef { } // Records a possibly-private value definition. -#[deriving(Clone)] +#[deriving(Clone, Show)] struct ValueNsDef { is_public: bool, // see note in ImportResolution about how to use this def: Def, @@ -1761,7 +1763,7 @@ impl<'a> Resolver<'a> { ident: Ident, new_parent: ReducedGraphParent) { debug!("(building reduced graph for \ - external crate) building external def, priv {:?}", + external crate) building external def, priv {}", vis); let is_public = vis == ast::Public; let is_exported = is_public && match new_parent { @@ -1900,13 +1902,13 @@ impl<'a> Resolver<'a> { } DefMethod(..) => { debug!("(building reduced graph for external crate) \ - ignoring {:?}", def); + ignoring {}", def); // Ignored; handled elsewhere. } DefLocal(..) | DefPrimTy(..) | DefTyParam(..) | DefUse(..) | DefUpvar(..) | DefRegion(..) | DefTyParamBinder(..) | DefLabel(..) | DefSelfTy(..) => { - fail!("didn't expect `{:?}`", def); + fail!("didn't expect `{}`", def); } } } @@ -2420,7 +2422,7 @@ impl<'a> Resolver<'a> { lp: LastPrivate) -> ResolveResult<()> { debug!("(resolving single import) resolving `{}` = `{}::{}` from \ - `{}` id {}, last private {:?}", + `{}` id {}, last private {}", token::get_ident(target), self.module_to_string(&*containing_module), token::get_ident(source), @@ -2522,7 +2524,7 @@ impl<'a> Resolver<'a> { shadowable: _ }) => { debug!("(resolving single import) found \ - import in ns {:?}", namespace); + import in ns {}", namespace); let id = import_resolution.id(namespace); // track used imports and extern crates as well this.used_imports.insert((id, namespace)); @@ -2596,7 +2598,7 @@ impl<'a> Resolver<'a> { match value_result { BoundResult(ref target_module, ref name_bindings) => { - debug!("(resolving single import) found value target: {:?}", + debug!("(resolving single import) found value target: {}", { name_bindings.value_def.borrow().clone().unwrap().def }); self.check_for_conflicting_import( &import_resolution.value_target, @@ -2619,7 +2621,7 @@ impl<'a> Resolver<'a> { } match type_result { BoundResult(ref target_module, ref name_bindings) => { - debug!("(resolving single import) found type target: {:?}", + debug!("(resolving single import) found type target: {}", { name_bindings.type_def.borrow().clone().unwrap().type_def }); self.check_for_conflicting_import( &import_resolution.type_target, @@ -2724,7 +2726,7 @@ impl<'a> Resolver<'a> { .borrow(); for (ident, target_import_resolution) in import_resolutions.iter() { debug!("(resolving glob import) writing module resolution \ - {:?} into `{}`", + {} into `{}`", target_import_resolution.type_target.is_none(), self.module_to_string(module_)); @@ -3305,7 +3307,7 @@ impl<'a> Resolver<'a> { namespace: Namespace) -> ResolveResult<(Target, bool)> { debug!("(resolving item in lexical scope) resolving `{}` in \ - namespace {:?} in `{}`", + namespace {} in `{}`", token::get_ident(name), namespace, self.module_to_string(&*module_)); @@ -3339,7 +3341,7 @@ impl<'a> Resolver<'a> { None => { // Not found; continue. debug!("(resolving item in lexical scope) found \ - import resolution, but not in namespace {:?}", + import resolution, but not in namespace {}", namespace); } Some(target) => { @@ -3620,7 +3622,7 @@ impl<'a> Resolver<'a> { match import_resolution.target_for_namespace(namespace) { None => { debug!("(resolving name in module) name found, \ - but not in namespace {:?}", + but not in namespace {}", namespace); } Some(target) => { @@ -3780,7 +3782,7 @@ impl<'a> Resolver<'a> { match namebindings.def_for_namespace(ns) { Some(d) => { let name = token::get_name(name); - debug!("(computing exports) YES: export '{}' => {:?}", + debug!("(computing exports) YES: export '{}' => {}", name, d.def_id()); exports2.push(Export2 { name: name.get().to_string(), @@ -3788,7 +3790,7 @@ impl<'a> Resolver<'a> { }); } d_opt => { - debug!("(computing exports) NO: {:?}", d_opt); + debug!("(computing exports) NO: {}", d_opt); } } } @@ -4447,7 +4449,7 @@ impl<'a> Resolver<'a> { Some(def) => { match def { (DefTrait(_), _) => { - debug!("(resolving trait) found trait def: {:?}", def); + debug!("(resolving trait) found trait def: {}", def); self.record_def(trait_reference.ref_id, def); } (def, _) => { @@ -4840,7 +4842,7 @@ impl<'a> Resolver<'a> { match self.resolve_path(ty.id, path, TypeNS, true) { Some(def) => { debug!("(resolving type) resolved `{}` to \ - type {:?}", + type {}", token::get_ident(path.segments .last().unwrap() .identifier), @@ -5124,7 +5126,7 @@ impl<'a> Resolver<'a> { } result => { debug!("(resolving pattern) didn't find struct \ - def: {:?}", result); + def: {}", result); let msg = format!("`{}` does not name a structure", self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); @@ -5148,7 +5150,7 @@ impl<'a> Resolver<'a> { ValueNS) { Success((target, _)) => { debug!("(resolve bare identifier pattern) succeeded in \ - finding {} at {:?}", + finding {} at {}", token::get_ident(name), target.bindings.value_def.borrow()); match *target.bindings.value_def.borrow() { @@ -5489,7 +5491,7 @@ impl<'a> Resolver<'a> { match search_result { Some(DlDef(def)) => { debug!("(resolving path in local ribs) resolved `{}` to \ - local: {:?}", + local: {}", token::get_ident(ident), def); return Some(def); @@ -5840,7 +5842,7 @@ impl<'a> Resolver<'a> { Some(definition) => self.record_def(expr.id, definition), result => { debug!("(resolving expression) didn't find struct \ - def: {:?}", result); + def: {}", result); let msg = format!("`{}` does not name a structure", self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); @@ -6026,7 +6028,7 @@ impl<'a> Resolver<'a> { } fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) { - debug!("(recording def) recording {:?} for {:?}, last private {:?}", + debug!("(recording def) recording {} for {}, last private {}", def, node_id, lp); assert!(match lp {LastImport{..} => false, _ => true}, "Import should only be used for `use` directives"); @@ -6038,8 +6040,8 @@ impl<'a> Resolver<'a> { // the same conclusion! - nmatsakis Occupied(entry) => if def != *entry.get() { self.session - .bug(format!("node_id {:?} resolved first to {:?} and \ - then {:?}", + .bug(format!("node_id {} resolved first to {} and \ + then {}", node_id, *entry.get(), def).as_slice()); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 6d84b8cb49d..6f517f1f166 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -57,6 +57,7 @@ struct LifetimeContext<'a> { scope: Scope<'a> } +#[deriving(Show)] enum ScopeChain<'a> { /// EarlyScope(i, ['a, 'b, ...], s) extends s with early-bound /// lifetimes, assigning indexes 'a => i, 'b => i+1, ... etc. @@ -118,10 +119,10 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { }; self.with(|_, f| f(EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE)), |v| { - debug!("entering scope {:?}", v.scope); + debug!("entering scope {}", v.scope); v.check_lifetime_defs(lifetimes); visit::walk_item(v, item); - debug!("exiting scope {:?}", v.scope); + debug!("exiting scope {}", v.scope); }); } @@ -268,7 +269,7 @@ impl<'a> LifetimeContext<'a> { let referenced_idents = early_bound_lifetime_names(generics); debug!("pushing fn scope id={} due to fn item/method\ - referenced_idents={:?}", + referenced_idents={}", n, referenced_idents.iter().map(lifetime_show).collect::<Vec<token::InternedString>>()); let lifetimes = &generics.lifetimes; @@ -439,7 +440,7 @@ impl<'a> LifetimeContext<'a> { probably a bug in syntax::fold"); } - debug!("lifetime_ref={} id={} resolved to {:?}", + debug!("lifetime_ref={} id={} resolved to {}", lifetime_to_string(lifetime_ref), lifetime_ref.id, def); diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index 21810b608b4..9dfde7ec084 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -246,7 +246,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { def::DefUse(_) | def::DefMethod(..) | def::DefPrimTy(_) => { - self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {:?}", + self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {}", def).as_slice()); }, } @@ -313,7 +313,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { }, _ => { self.sess.span_bug(method.span, - format!("Container {} for method {} is not a node item {:?}", + format!("Container {} for method {} is not a node item {}", impl_id.node, method.id, self.analysis.ty_cx.map.get(impl_id.node) @@ -1415,7 +1415,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { // FIXME(nrc) what is this doing here? def::DefStatic(_, _) => {} def::DefConst(..) => {} - _ => error!("unexpected definition kind when processing collected paths: {:?}", + _ => error!("unexpected definition kind when processing collected paths: {}", *def) } } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 3a1058c009f..c31a3730a7c 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -226,6 +226,7 @@ use syntax::codemap::Span; use syntax::fold::Folder; use syntax::ptr::P; +#[deriving(Show)] struct ConstantExpr<'a>(&'a ast::Expr); impl<'a> ConstantExpr<'a> { @@ -240,6 +241,7 @@ impl<'a> ConstantExpr<'a> { } // An option identifying a branch (either a literal, an enum variant or a range) +#[deriving(Show)] enum Opt<'a> { ConstantValue(ConstantExpr<'a>), ConstantRange(ConstantExpr<'a>, ConstantExpr<'a>), @@ -519,7 +521,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>( variant_size: uint, val: ValueRef) -> Vec<Match<'a, 'p, 'blk, 'tcx>> { - debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})", + debug!("enter_opt(bcx={}, m={}, opt={}, col={}, val={})", bcx.to_str(), m.repr(bcx.tcx()), *opt, @@ -863,7 +865,7 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, _ => {} } - debug!("binding {:?} to {}", + debug!("binding {} to {}", binding_info.id, bcx.val_to_string(llval)); bcx.fcx.lllocals.borrow_mut().insert(binding_info.id, datum); @@ -1048,7 +1050,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // Decide what kind of branch we need let opts = get_branches(bcx, m, col); - debug!("options={:?}", opts); + debug!("options={}", opts); let mut kind = NoBranch; let mut test_val = val; debug!("test_val={}", bcx.val_to_string(test_val)); diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index f88b010c28a..2f06f16ace1 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -74,7 +74,7 @@ type Hint = attr::ReprAttr; /// Representations. -#[deriving(Eq, PartialEq)] +#[deriving(Eq, PartialEq, Show)] pub enum Repr { /// C-like enums; basically an int. CEnum(IntType, Disr, Disr), // discriminant range (signedness based on the IntType) @@ -127,7 +127,7 @@ pub enum Repr { } /// For structs, and struct-like parts of anything fancier. -#[deriving(Eq, PartialEq)] +#[deriving(Eq, PartialEq, Show)] pub struct Struct { // If the struct is DST, then the size and alignment do not take into // account the unsized fields of the struct. @@ -156,7 +156,7 @@ pub fn represent_type(cx: &CrateContext, t: ty::t) -> Rc<Repr> { } let repr = Rc::new(represent_type_uncached(cx, t)); - debug!("Represented as: {:?}", repr) + debug!("Represented as: {}", repr) cx.adt_reprs().borrow_mut().insert(t, repr.clone()); repr } @@ -371,6 +371,7 @@ fn mk_struct(cx: &CrateContext, tys: &[ty::t], packed: bool) -> Struct { } } +#[deriving(Show)] struct IntBounds { slo: i64, shi: i64, @@ -387,7 +388,7 @@ fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr { } fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntType { - debug!("range_to_inttype: {:?} {:?}", hint, bounds); + debug!("range_to_inttype: {} {}", hint, bounds); // Lists of sizes to try. u64 is always allowed as a fallback. #[allow(non_uppercase_statics)] static choose_shortest: &'static[IntType] = &[ @@ -440,7 +441,7 @@ pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type { } fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool { - debug!("bounds_usable: {:?} {:?}", ity, bounds); + debug!("bounds_usable: {} {}", ity, bounds); match ity { attr::SignedInt(_) => { let lllo = C_integral(ll_inttype(cx, ity), bounds.slo as u64, true); @@ -538,7 +539,7 @@ fn generic_type_of(cx: &CrateContext, Type::array(&Type::i64(cx), align_units), a if a.count_ones() == 1 => Type::array(&Type::vector(&Type::i32(cx), a / 4), align_units), - _ => fail!("unsupported enum alignment: {:?}", align) + _ => fail!("unsupported enum alignment: {}", align) }; assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align); assert_eq!(align % discr_size, 0); diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index d898931cb33..f4586fca52f 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -101,7 +101,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) constraints.push_str(clobbers.as_slice()); } - debug!("Asm Constraints: {:?}", constraints.as_slice()); + debug!("Asm Constraints: {}", constraints.as_slice()); let num_outputs = outputs.len(); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index ebc46bb2bfc..c5b0e10f093 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1088,7 +1088,7 @@ pub fn ignore_lhs(_bcx: Block, local: &ast::Local) -> bool { pub fn init_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, local: &ast::Local) -> Block<'blk, 'tcx> { - debug!("init_local(bcx={}, local.id={:?})", bcx.to_str(), local.id); + debug!("init_local(bcx={}, local.id={})", bcx.to_str(), local.id); let _indenter = indenter(); let _icx = push_ctxt("init_local"); _match::store_local(bcx, local) @@ -2672,7 +2672,7 @@ fn contains_null(s: &str) -> bool { } pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { - debug!("get_item_val(id=`{:?}`)", id); + debug!("get_item_val(id=`{}`)", id); match ccx.item_vals().borrow().find_copy(&id) { Some(v) => return v, @@ -2857,7 +2857,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef { } ref variant => { - ccx.sess().bug(format!("get_item_val(): unexpected variant: {:?}", + ccx.sess().bug(format!("get_item_val(): unexpected variant: {}", variant).as_slice()) } }; diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index 11cf2402782..dbc668a04ba 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -795,11 +795,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { else { llvm::False }; let argtys = inputs.iter().map(|v| { - debug!("Asm Input Type: {:?}", self.ccx.tn().val_to_string(*v)); + debug!("Asm Input Type: {}", self.ccx.tn().val_to_string(*v)); val_ty(*v) }).collect::<Vec<_>>(); - debug!("Asm Output Type: {:?}", self.ccx.tn().type_to_string(output)); + debug!("Asm Output Type: {}", self.ccx.tn().type_to_string(output)); let fty = Type::func(argtys.as_slice(), &output); unsafe { let v = llvm::LLVMInlineAsm( diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index bb32fdcea7e..f607dfdd17f 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -209,7 +209,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) def::DefSelfTy(..) => { bcx.tcx().sess.span_bug( ref_expr.span, - format!("cannot translate def {:?} \ + format!("cannot translate def {} \ to a callable thing!", def).as_slice()); } } @@ -226,7 +226,7 @@ pub fn trans_fn_ref(bcx: Block, def_id: ast::DefId, node: ExprOrMethodCall) -> V let _icx = push_ctxt("trans_fn_ref"); let substs = node_id_substs(bcx, node); - debug!("trans_fn_ref(def_id={}, node={:?}, substs={})", + debug!("trans_fn_ref(def_id={}, node={}, substs={})", def_id.repr(bcx.tcx()), node, substs.repr(bcx.tcx())); @@ -398,7 +398,7 @@ pub fn trans_fn_ref_with_substs( let ccx = bcx.ccx(); let tcx = bcx.tcx(); - debug!("trans_fn_ref_with_substs(bcx={}, def_id={}, node={:?}, \ + debug!("trans_fn_ref_with_substs(bcx={}, def_id={}, node={}, \ substs={})", bcx.to_str(), def_id.repr(tcx), diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index f3844a956fa..9edca215aef 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -23,6 +23,7 @@ use middle::trans::debuginfo; use middle::trans::glue; use middle::trans::type_::Type; use middle::ty; +use std::fmt; use syntax::ast; use util::ppaux::Repr; @@ -45,6 +46,7 @@ pub struct CleanupScope<'blk, 'tcx: 'blk> { cached_landing_pad: Option<BasicBlockRef>, } +#[deriving(Show)] pub struct CustomScopeIndex { index: uint } @@ -59,7 +61,23 @@ pub enum CleanupScopeKind<'blk, 'tcx: 'blk> { LoopScopeKind(ast::NodeId, [Block<'blk, 'tcx>, ..EXIT_MAX]) } -#[deriving(PartialEq)] +impl<'blk, 'tcx: 'blk> fmt::Show for CleanupScopeKind<'blk, 'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::FormatError> { + match *self { + CustomScopeKind => write!(f, "CustomScopeKind"), + AstScopeKind(nid) => write!(f, "AstScopeKind({})", nid), + LoopScopeKind(nid, ref blks) => { + try!(write!(f, "LoopScopeKind({}, [", nid)); + for blk in blks.iter() { + try!(write!(f, "{:p}, ", blk)); + } + write!(f, "])") + } + } + } +} + +#[deriving(PartialEq, Show)] pub enum EarlyExitLabel { UnwindExit, ReturnExit, @@ -83,6 +101,7 @@ pub trait Cleanup { pub type CleanupObj = Box<Cleanup+'static>; +#[deriving(Show)] pub enum ScopeId { AstScope(ast::NodeId), CustomScope(CustomScopeIndex) @@ -222,7 +241,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { * cleanups for normal exit. */ - debug!("pop_and_trans_custom_cleanup_scope({:?})", custom_scope); + debug!("pop_and_trans_custom_cleanup_scope({})", custom_scope); assert!(self.is_valid_to_pop_custom_scope(custom_scope)); let scope = self.pop_scope(); @@ -273,7 +292,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { ptr: val, }; - debug!("schedule_lifetime_end({:?}, val={})", + debug!("schedule_lifetime_end({}, val={})", cleanup_scope, self.ccx.tn().val_to_string(val)); @@ -298,7 +317,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: false }; - debug!("schedule_drop_mem({:?}, val={}, ty={})", + debug!("schedule_drop_mem({}, val={}, ty={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx())); @@ -324,7 +343,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: true }; - debug!("schedule_drop_and_zero_mem({:?}, val={}, ty={}, zero={})", + debug!("schedule_drop_and_zero_mem({}, val={}, ty={}, zero={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx()), @@ -350,7 +369,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { zero: false }; - debug!("schedule_drop_immediate({:?}, val={}, ty={})", + debug!("schedule_drop_immediate({}, val={}, ty={})", cleanup_scope, self.ccx.tn().val_to_string(val), ty.repr(self.ccx.tcx())); @@ -370,7 +389,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty }; - debug!("schedule_free_value({:?}, val={}, heap={:?})", + debug!("schedule_free_value({}, val={}, heap={})", cleanup_scope, self.ccx.tn().val_to_string(val), heap); @@ -391,7 +410,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { let drop = box FreeSlice { ptr: val, size: size, align: align, heap: heap }; - debug!("schedule_free_slice({:?}, val={}, heap={:?})", + debug!("schedule_free_slice({}, val={}, heap={})", cleanup_scope, self.ccx.tn().val_to_string(val), heap); @@ -417,7 +436,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { * in the topmost scope, which must be a temporary scope. */ - debug!("schedule_clean_in_ast_scope(cleanup_scope={:?})", + debug!("schedule_clean_in_ast_scope(cleanup_scope={})", cleanup_scope); for scope in self.scopes.borrow_mut().iter_mut().rev() { @@ -598,7 +617,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx * perform all cleanups and finally branch to the `break_blk`. */ - debug!("trans_cleanups_to_exit_scope label={:?} scopes={}", + debug!("trans_cleanups_to_exit_scope label={} scopes={}", label, self.scopes_len()); let orig_scopes_len = self.scopes_len(); @@ -634,7 +653,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx LoopExit(id, _) => { self.ccx.sess().bug(format!( - "cannot exit from scope {:?}, \ + "cannot exit from scope {}, \ not in scope", id).as_slice()); } } @@ -968,6 +987,7 @@ impl Cleanup for DropValue { } } +#[deriving(Show)] pub enum Heap { HeapExchange } @@ -1072,7 +1092,7 @@ pub fn temporary_scope(tcx: &ty::ctxt, match tcx.region_maps.temporary_scope(id) { Some(scope) => { let r = AstScope(scope); - debug!("temporary_scope({}) = {:?}", id, r); + debug!("temporary_scope({}) = {}", id, r); r } None => { @@ -1086,7 +1106,7 @@ pub fn var_scope(tcx: &ty::ctxt, id: ast::NodeId) -> ScopeId { let r = AstScope(tcx.region_maps.var_scope(id)); - debug!("var_scope({}) = {:?}", id, r); + debug!("var_scope({}) = {}", id, r); r } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 1e2e8c589c6..8f877f981c8 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -550,7 +550,7 @@ pub fn get_wrapper_for_bare_fn(ccx: &CrateContext, _ => { ccx.sess().bug(format!("get_wrapper_for_bare_fn: \ expected a statically resolved fn, got \ - {:?}", + {}", def).as_slice()); } }; diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 9c1fcaa9ce8..8f0ea7a85d4 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -468,7 +468,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { Some(v) => v.clone(), None => { self.tcx().sess.bug(format!( - "no def associated with node id {:?}", nid).as_slice()); + "no def associated with node id {}", nid).as_slice()); } } } @@ -704,7 +704,7 @@ pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint]) unsafe { let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint); - debug!("const_get_elt(v={}, us={:?}, r={})", + debug!("const_get_elt(v={}, us={}, r={})", cx.tn().val_to_string(v), us, cx.tn().val_to_string(r)); return r; @@ -865,7 +865,7 @@ pub fn fulfill_obligation(ccx: &CrateContext, } // Key used to lookup values supplied for type parameters in an expr. -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum ExprOrMethodCall { // Type parameters for a path like `None::<int>` ExprId(ast::NodeId), @@ -891,7 +891,7 @@ pub fn node_id_substs(bcx: Block, if substs.types.any(|t| ty::type_needs_infer(*t)) { bcx.sess().bug( - format!("type parameters for node {:?} include inference types: \ + format!("type parameters for node {} include inference types: \ {}", node, substs.repr(bcx.tcx())).as_slice()); diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index ec357f7bfd7..d83c46be14a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -210,7 +210,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) { ty::AdjustAddEnv(store) => { cx.sess() .span_bug(e.span, - format!("unexpected static function: {:?}", + format!("unexpected static function: {}", store).as_slice()) } ty::AdjustDerefRef(ref adj) => { @@ -279,7 +279,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) { cx.sess() .span_bug(e.span, format!("unimplemented const \ - autoref {:?}", + autoref {}", autoref).as_slice()) } } diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 424007519af..fe9f832e44a 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -138,7 +138,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, els: Option<&ast::Expr>, dest: expr::Dest) -> Block<'blk, 'tcx> { - debug!("trans_if(bcx={}, if_id={}, cond={}, thn={:?}, dest={})", + debug!("trans_if(bcx={}, if_id={}, cond={}, thn={}, dest={})", bcx.to_str(), if_id, bcx.expr_to_string(cond), thn.id, dest.to_string(bcx.ccx())); let _icx = push_ctxt("trans_if"); @@ -429,7 +429,7 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match bcx.tcx().def_map.borrow().find(&expr_id) { Some(&def::DefLabel(loop_id)) => loop_id, ref r => { - bcx.tcx().sess.bug(format!("{:?} in def-map for label", + bcx.tcx().sess.bug(format!("{} in def-map for label", r).as_slice()) } } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 260bde0f07f..ea6d9e1dd8c 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -25,6 +25,7 @@ use middle::trans::type_of; use middle::ty; use util::ppaux::{ty_to_string}; +use std::fmt; use syntax::ast; /** @@ -51,6 +52,7 @@ pub struct DatumBlock<'blk, 'tcx: 'blk, K> { pub datum: Datum<K>, } +#[deriving(Show)] pub enum Expr { /// a fresh value that was produced and which has no cleanup yet /// because it has not yet "landed" into its permanent home @@ -62,9 +64,10 @@ pub enum Expr { LvalueExpr, } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Lvalue; +#[deriving(Show)] pub struct Rvalue { pub mode: RvalueMode } @@ -80,7 +83,7 @@ impl Drop for Rvalue { fn drop(&mut self) { } } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub enum RvalueMode { /// `val` is a pointer to the actual value (and thus has type *T) ByRef, @@ -539,7 +542,7 @@ impl Datum<Lvalue> { /** * Generic methods applicable to any sort of datum. */ -impl<K:KindOps> Datum<K> { +impl<K: KindOps + fmt::Show> Datum<K> { pub fn new(val: ValueRef, ty: ty::t, kind: K) -> Datum<K> { Datum { val: val, ty: ty, kind: kind } } @@ -615,7 +618,7 @@ impl<K:KindOps> Datum<K> { #[allow(dead_code)] // useful for debugging pub fn to_string(&self, ccx: &CrateContext) -> String { - format!("Datum({}, {}, {:?})", + format!("Datum({}, {}, {})", ccx.tn().val_to_string(self.val), ty_to_string(ccx.tcx(), self.ty), self.kind) @@ -658,7 +661,7 @@ impl<'blk, 'tcx, K> DatumBlock<'blk, 'tcx, K> { } } -impl<'blk, 'tcx, K:KindOps> DatumBlock<'blk, 'tcx, K> { +impl<'blk, 'tcx, K: KindOps + fmt::Show> DatumBlock<'blk, 'tcx, K> { pub fn to_expr_datumblock(self) -> DatumBlock<'blk, 'tcx, Expr> { DatumBlock::new(self.bcx, self.datum.to_expr_datum()) } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d81f78f23ff..4e3eaf26f42 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -468,7 +468,7 @@ impl TypeMap { &mut unique_type_id); }, _ => { - cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", + cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {}", ppaux::ty_to_string(cx.tcx(), type_).as_slice(), ty::get(type_).sty).as_slice()) } @@ -783,14 +783,14 @@ pub fn create_global_var_metadata(cx: &CrateContext, format!("debuginfo::\ create_global_var_metadata() - Captured var-id refers to \ - unexpected ast_item variant: {:?}", + unexpected ast_item variant: {}", var_item).as_slice()) } } }, _ => cx.sess().bug(format!("debuginfo::create_global_var_metadata() \ - Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", var_item).as_slice()) }; @@ -846,7 +846,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) { Some(datum) => datum, None => { bcx.sess().span_bug(span, - format!("no entry in lllocals table for {:?}", + format!("no entry in lllocals table for {}", node_id).as_slice()); } }; @@ -896,7 +896,7 @@ pub fn create_captured_var_metadata(bcx: Block, format!( "debuginfo::create_captured_var_metadata() - \ Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", ast_item).as_slice()); } } @@ -906,7 +906,7 @@ pub fn create_captured_var_metadata(bcx: Block, .span_bug(span, format!("debuginfo::create_captured_var_metadata() - \ Captured var-id refers to unexpected \ - ast_map variant: {:?}", + ast_map variant: {}", ast_item).as_slice()); } }; @@ -1009,7 +1009,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) { Some(v) => v, None => { bcx.sess().span_bug(span, - format!("no entry in lllocals table for {:?}", + format!("no entry in lllocals table for {}", node_id).as_slice()); } }; @@ -1250,7 +1250,7 @@ pub fn create_function_debug_context(cx: &CrateContext, _ => { cx.sess() .bug(format!("create_function_debug_context: \ - unexpected sort of node: {:?}", + unexpected sort of node: {}", fnitem).as_slice()) } } @@ -1261,7 +1261,7 @@ pub fn create_function_debug_context(cx: &CrateContext, return FunctionDebugContext { repr: FunctionWithoutDebugInfo }; } _ => cx.sess().bug(format!("create_function_debug_context: \ - unexpected sort of node: {:?}", + unexpected sort of node: {}", fnitem).as_slice()) }; @@ -1542,7 +1542,7 @@ fn compile_unit_metadata(cx: &CrateContext) { } }; - debug!("compile_unit_metadata: {:?}", compile_unit_name); + debug!("compile_unit_metadata: {}", compile_unit_name); let producer = format!("rustc version {}", (option_env!("CFG_VERSION")).expect("CFG_VERSION")); @@ -1703,7 +1703,7 @@ fn scope_metadata(fcx: &FunctionContext, let node = fcx.ccx.tcx().map.get(node_id); fcx.ccx.sess().span_bug(error_reporting_span, - format!("debuginfo: Could not find scope info for node {:?}", + format!("debuginfo: Could not find scope info for node {}", node).as_slice()); } } @@ -1711,7 +1711,7 @@ fn scope_metadata(fcx: &FunctionContext, fn basic_type_metadata(cx: &CrateContext, t: ty::t) -> DIType { - debug!("basic_type_metadata: {:?}", ty::get(t)); + debug!("basic_type_metadata: {}", ty::get(t)); let (name, encoding) = match ty::get(t).sty { ty::ty_nil => ("()".to_string(), DW_ATE_unsigned), @@ -2855,7 +2855,7 @@ fn type_metadata(cx: &CrateContext, } }; - debug!("type_metadata: {:?}", ty::get(t)); + debug!("type_metadata: {}", ty::get(t)); let sty = &ty::get(t).sty; let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty { @@ -2937,7 +2937,7 @@ fn type_metadata(cx: &CrateContext, usage_site_span).finalize(cx) } _ => { - cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}", + cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {}", sty).as_slice()) } }; @@ -3991,7 +3991,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree Some(node) => node, None => { cx.sess().bug(format!("debuginfo::namespace_for_item(): \ - path too short for {:?}", + path too short for {}", def_id).as_slice()); } } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 19c9c5e0119..bcbc9fff834 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -666,7 +666,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_datum_unadjusted reached \ - fall-through case: {:?}", + fall-through case: {}", expr.node).as_slice()); } } @@ -982,7 +982,7 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_stmt_unadjusted reached \ - fall-through case: {:?}", + fall-through case: {}", expr.node).as_slice()); } } @@ -1128,7 +1128,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, format!("trans_rvalue_dps_unadjusted reached fall-through \ - case: {:?}", + case: {}", expr.node).as_slice()); } } @@ -1176,7 +1176,7 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } _ => { bcx.tcx().sess.span_bug(ref_expr.span, format!( - "Non-DPS def {:?} referened by {}", + "Non-DPS def {} referened by {}", def, bcx.node_id_to_string(ref_expr.id)).as_slice()); } } @@ -1200,7 +1200,7 @@ fn trans_def_fn_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } _ => { bcx.tcx().sess.span_bug(ref_expr.span, format!( - "trans_def_fn_unadjusted invoked on: {:?} for {}", + "trans_def_fn_unadjusted invoked on: {} for {}", def, ref_expr.repr(bcx.tcx())).as_slice()); } @@ -1228,7 +1228,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, Some(&val) => Datum::new(val, local_ty, Lvalue), None => { bcx.sess().bug(format!( - "trans_local_var: no llval for upvar {:?} found", + "trans_local_var: no llval for upvar {} found", nid).as_slice()); } } @@ -1238,17 +1238,17 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, Some(&v) => v, None => { bcx.sess().bug(format!( - "trans_local_var: no datum for local/arg {:?} found", + "trans_local_var: no datum for local/arg {} found", nid).as_slice()); } }; - debug!("take_local(nid={:?}, v={}, ty={})", + debug!("take_local(nid={}, v={}, ty={})", nid, bcx.val_to_string(datum.val), bcx.ty_to_string(datum.ty)); datum } _ => { bcx.sess().unimpl(format!( - "unsupported def type in trans_local_var: {:?}", + "unsupported def type in trans_local_var: {}", def).as_slice()); } } @@ -1869,7 +1869,7 @@ fn float_cast(bcx: Block, } else { llsrc }; } -#[deriving(PartialEq)] +#[deriving(PartialEq, Show)] pub enum cast_kind { cast_pointer, cast_integral, @@ -1981,7 +1981,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, cast_float => SIToFP(bcx, lldiscrim_a, ll_t_out), _ => { ccx.sess().bug(format!("translating unsupported cast: \ - {} ({:?}) -> {} ({:?})", + {} ({}) -> {} ({})", t_in.repr(bcx.tcx()), k_in, t_out.repr(bcx.tcx()), @@ -1990,7 +1990,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } _ => ccx.sess().bug(format!("translating unsupported cast: \ - {} ({:?}) -> {} ({:?})", + {} ({}) -> {} ({})", t_in.repr(bcx.tcx()), k_in, t_out.repr(bcx.tcx()), diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index e47adb6bc0e..cc28b803208 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -474,7 +474,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llforeign_align = machine::llalign_of_min(ccx, llforeign_ret_ty); let llrust_align = machine::llalign_of_min(ccx, llrust_ret_ty); let llalign = cmp::min(llforeign_align, llrust_align); - debug!("llrust_size={:?}", llrust_size); + debug!("llrust_size={}", llrust_size); base::call_memcpy(bcx, llretptr_i8, llscratch_i8, C_uint(ccx, llrust_size as uint), llalign as u32); } @@ -576,7 +576,7 @@ pub fn register_rust_fn_with_foreign_abi(ccx: &CrateContext, }; let llfn = base::register_fn_llvmty(ccx, sp, sym, node_id, cconv, llfn_ty); add_argument_attributes(&tys, llfn); - debug!("register_rust_fn_with_foreign_abi(node_id={:?}, llfn_ty={}, llfn={})", + debug!("register_rust_fn_with_foreign_abi(node_id={}, llfn_ty={}, llfn={})", node_id, ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn)); llfn } diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index eb53fe2d673..0b3f1c9840c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -60,7 +60,7 @@ pub fn trans_impl(ccx: &CrateContext, let _icx = push_ctxt("meth::trans_impl"); let tcx = ccx.tcx(); - debug!("trans_impl(name={}, id={:?})", name.repr(tcx), id); + debug!("trans_impl(name={}, id={})", name.repr(tcx), id); // Both here and below with generic methods, be sure to recurse and look for // items that we need to translate. @@ -174,8 +174,8 @@ pub fn trans_static_method_callee(bcx: Block, let _icx = push_ctxt("meth::trans_static_method_callee"); let ccx = bcx.ccx(); - debug!("trans_static_method_callee(method_id={:?}, trait_id={}, \ - expr_id={:?})", + debug!("trans_static_method_callee(method_id={}, trait_id={}, \ + expr_id={})", method_id, ty::item_path_str(bcx.tcx(), trait_id), expr_id); diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs index e2c1bf1d8d1..258d12e631f 100644 --- a/src/librustc/middle/trans/monomorphize.rs +++ b/src/librustc/middle/trans/monomorphize.rs @@ -38,7 +38,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, debug!("monomorphic_fn(\ fn_id={}, \ real_substs={}, \ - ref_id={:?})", + ref_id={})", fn_id.repr(ccx.tcx()), real_substs.repr(ccx.tcx()), ref_id); @@ -70,7 +70,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, debug!("monomorphic_fn(\ fn_id={}, \ psubsts={}, \ - hash_id={:?})", + hash_id={})", fn_id.repr(ccx.tcx()), psubsts.repr(ccx.tcx()), hash_id); @@ -82,7 +82,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, ccx.sess(), ccx.tcx().map.find(fn_id.node), || { - format!("while monomorphizing {:?}, couldn't find it in \ + format!("while monomorphizing {}, couldn't find it in \ the item map (may have attempted to monomorphize \ an item defined in a different crate?)", fn_id) @@ -247,7 +247,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, d } _ => { - ccx.sess().bug(format!("can't monomorphize a {:?}", + ccx.sess().bug(format!("can't monomorphize a {}", map_node).as_slice()) } } @@ -273,7 +273,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, ast_map::NodeBlock(..) | ast_map::NodePat(..) | ast_map::NodeLocal(..) => { - ccx.sess().bug(format!("can't monomorphize a {:?}", + ccx.sess().bug(format!("can't monomorphize a {}", map_node).as_slice()) } }; @@ -284,7 +284,7 @@ pub fn monomorphic_fn(ccx: &CrateContext, (lldecl, true) } -#[deriving(PartialEq, Eq, Hash)] +#[deriving(PartialEq, Eq, Hash, Show)] pub struct MonoId { pub def: ast::DefId, pub params: subst::VecPerParamSpace<ty::t> diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index fac0ef2014e..a404d9d221e 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -118,7 +118,7 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // to store the array of the suitable size, so all we have to do is // generate the content. - debug!("trans_fixed_vstore(expr={}, dest={:?})", + debug!("trans_fixed_vstore(expr={}, dest={})", bcx.expr_to_string(expr), dest.to_string(bcx.ccx())); let vt = vec_types_from_expr(bcx, expr); @@ -175,7 +175,7 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Handle the &[...] case: let vt = vec_types_from_expr(bcx, content_expr); let count = elements_required(bcx, content_expr); - debug!(" vt={}, count={:?}", vt.to_string(ccx), count); + debug!(" vt={}, count={}", vt.to_string(ccx), count); let llcount = C_uint(ccx, count); let fixed_ty = ty::mk_vec(bcx.tcx(), @@ -249,7 +249,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let fcx = bcx.fcx; let mut bcx = bcx; - debug!("write_content(vt={}, dest={}, vstore_expr={:?})", + debug!("write_content(vt={}, dest={}, vstore_expr={})", vt.to_string(bcx.ccx()), dest.to_string(bcx.ccx()), bcx.expr_to_string(vstore_expr)); @@ -291,7 +291,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let temp_scope = fcx.push_custom_cleanup_scope(); for (i, element) in elements.iter().enumerate() { let lleltptr = GEPi(bcx, lldest, [i]); - debug!("writing index {:?} with lleltptr={:?}", + debug!("writing index {} with lleltptr={}", i, bcx.val_to_string(lleltptr)); bcx = expr::trans_into(bcx, &**element, SaveIn(lleltptr)); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index d41cd7ed9e5..e723d5af89c 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -253,7 +253,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { None => () } - debug!("type_of {} {:?}", t.repr(cx.tcx()), ty::get(t).sty); + debug!("type_of {} {}", t.repr(cx.tcx()), ty::get(t).sty); // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain @@ -264,7 +264,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { if t != t_norm { let llty = type_of(cx, t_norm); - debug!("--> normalized {} {:?} to {} {:?} llty={}", + debug!("--> normalized {} {} to {} {} llty={}", t.repr(cx.tcx()), t, t_norm.repr(cx.tcx()), @@ -378,7 +378,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_err(..) => cx.sess().bug("type_of with ty_err"), }; - debug!("--> mapped t={} {:?} to llty={}", + debug!("--> mapped t={} {} to llty={}", t.repr(cx.tcx()), t, cx.tn().type_to_string(llty)); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 06d36230068..d026b31b914 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -70,7 +70,7 @@ pub struct field { pub mt: mt } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum ImplOrTraitItemContainer { TraitContainer(ast::DefId), ImplContainer(ast::DefId), @@ -138,7 +138,7 @@ impl ImplOrTraitItemId { } } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct Method { pub ident: ast::Ident, pub generics: ty::Generics, @@ -268,13 +268,13 @@ pub enum Variance { Bivariant, // T<A> <: T<B> -- e.g., unused type parameter } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum AutoAdjustment { AdjustAddEnv(ty::TraitStore), AdjustDerefRef(AutoDerefRef) } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum UnsizeKind { // [T, ..n] -> [T], the uint field is n. UnsizeLength(uint), @@ -284,13 +284,13 @@ pub enum UnsizeKind { UnsizeVtable(TyTrait, /* the self type of the trait */ ty::t) } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct AutoDerefRef { pub autoderefs: uint, pub autoref: Option<AutoRef> } -#[deriving(Clone, PartialEq)] +#[deriving(Clone, PartialEq, Show)] pub enum AutoRef { /// Convert from T to &T /// The third field allows us to wrap other AutoRef adjustments. @@ -726,7 +726,7 @@ pub enum Region { * the original var id (that is, the root variable that is referenced * by the upvar) and the id of the closure expression. */ -#[deriving(Clone, PartialEq, Eq, Hash)] +#[deriving(Clone, PartialEq, Eq, Hash, Show)] pub struct UpvarId { pub var_id: ast::NodeId, pub closure_expr_id: ast::NodeId, @@ -827,7 +827,7 @@ pub enum BorrowKind { * the closure, so sometimes it is necessary for them to be larger * than the closure lifetime itself. */ -#[deriving(PartialEq, Clone, Encodable, Decodable)] +#[deriving(PartialEq, Clone, Encodable, Decodable, Show)] pub struct UpvarBorrow { pub kind: BorrowKind, pub region: ty::Region, @@ -1434,7 +1434,7 @@ pub struct UnboxedClosure { pub kind: UnboxedClosureKind, } -#[deriving(Clone, PartialEq, Eq)] +#[deriving(Clone, PartialEq, Eq, Show)] pub enum UnboxedClosureKind { FnUnboxedClosureKind, FnMutUnboxedClosureKind, @@ -3133,7 +3133,7 @@ pub fn fn_is_variadic(fty: t) -> bool { ty_bare_fn(ref f) => f.sig.variadic, ty_closure(ref f) => f.sig.variadic, ref s => { - fail!("fn_is_variadic() called on non-fn type: {:?}", s) + fail!("fn_is_variadic() called on non-fn type: {}", s) } } } @@ -3143,7 +3143,7 @@ pub fn ty_fn_sig(fty: t) -> FnSig { ty_bare_fn(ref f) => f.sig.clone(), ty_closure(ref f) => f.sig.clone(), ref s => { - fail!("ty_fn_sig() called on non-fn type: {:?}", s) + fail!("ty_fn_sig() called on non-fn type: {}", s) } } } @@ -3163,7 +3163,7 @@ pub fn ty_fn_args(fty: t) -> Vec<t> { ty_bare_fn(ref f) => f.sig.inputs.clone(), ty_closure(ref f) => f.sig.inputs.clone(), ref s => { - fail!("ty_fn_args() called on non-fn type: {:?}", s) + fail!("ty_fn_args() called on non-fn type: {}", s) } } } @@ -3177,7 +3177,7 @@ pub fn ty_closure_store(fty: t) -> TraitStore { UniqTraitStore } ref s => { - fail!("ty_closure_store() called on non-closure type: {:?}", s) + fail!("ty_closure_store() called on non-closure type: {}", s) } } } @@ -3187,7 +3187,7 @@ pub fn ty_fn_ret(fty: t) -> t { ty_bare_fn(ref f) => f.sig.output, ty_closure(ref f) => f.sig.output, ref s => { - fail!("ty_fn_ret() called on non-fn type: {:?}", s) + fail!("ty_fn_ret() called on non-fn type: {}", s) } } } @@ -3208,7 +3208,7 @@ pub fn ty_region(tcx: &ctxt, ref s => { tcx.sess.span_bug( span, - format!("ty_region() invoked on an inappropriate ty: {:?}", + format!("ty_region() invoked on an inappropriate ty: {}", s).as_slice()); } } @@ -3272,7 +3272,7 @@ pub fn expr_span(cx: &ctxt, id: NodeId) -> Span { e.span } Some(f) => { - cx.sess.bug(format!("Node id {} is not an expr: {:?}", + cx.sess.bug(format!("Node id {} is not an expr: {}", id, f).as_slice()); } @@ -3292,14 +3292,14 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString { } _ => { cx.sess.bug( - format!("Variable id {} maps to {:?}, not local", + format!("Variable id {} maps to {}, not local", id, pat).as_slice()); } } } r => { - cx.sess.bug(format!("Variable id {} maps to {:?}, not local", + cx.sess.bug(format!("Variable id {} maps to {}, not local", id, r).as_slice()); } @@ -3343,7 +3343,7 @@ pub fn adjust_ty(cx: &ctxt, ref b => { cx.sess.bug( format!("add_env adjustment on non-bare-fn: \ - {:?}", + {}", b).as_slice()); } } @@ -3456,7 +3456,7 @@ pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def { Some(&def) => def, None => { tcx.sess.span_bug(expr.span, format!( - "no def-map entry for expr {:?}", expr.id).as_slice()); + "no def-map entry for expr {}", expr.id).as_slice()); } } } @@ -3547,7 +3547,7 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { def => { tcx.sess.span_bug( expr.span, - format!("uncategorized def for expr {:?}: {:?}", + format!("uncategorized def for expr {}: {}", expr.id, def).as_slice()); } @@ -3671,7 +3671,7 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field]) let mut i = 0u; for f in fields.iter() { if f.ident.name == name { return i; } i += 1u; } tcx.sess.bug(format!( - "no field named `{}` found in the list of fields `{:?}`", + "no field named `{}` found in the list of fields `{}`", token::get_name(name), fields.iter() .map(|f| token::get_ident(f.ident).get().to_string()) @@ -3965,7 +3965,7 @@ fn lookup_locally_or_in_crate_store<V:Clone>( } if def_id.krate == ast::LOCAL_CRATE { - fail!("No def'n found for {:?} in tcx.{}", def_id, descr); + fail!("No def'n found for {} in tcx.{}", def_id, descr); } let v = load_external(); map.insert(def_id, v.clone()); @@ -4083,7 +4083,7 @@ pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId) pub fn impl_trait_ref(cx: &ctxt, id: ast::DefId) -> Option<Rc<TraitRef>> { memoized(&cx.impl_trait_cache, id, |id: ast::DefId| { if id.krate == ast::LOCAL_CRATE { - debug!("(impl_trait_ref) searching for trait impl {:?}", id); + debug!("(impl_trait_ref) searching for trait impl {}", id); match cx.map.find(id.node) { Some(ast_map::NodeItem(item)) => { match item.node { @@ -5418,7 +5418,7 @@ impl<'tcx> mc::Typer<'tcx> for ty::ctxt<'tcx> { } /// The category of explicit self. -#[deriving(Clone, Eq, PartialEq)] +#[deriving(Clone, Eq, PartialEq, Show)] pub enum ExplicitSelfCategory { StaticExplicitSelfCategory, ByValueExplicitSelfCategory, diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index efd0a2a0e48..0e9d255adf9 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -961,7 +961,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( _ => { tcx.sess.span_fatal(ast_ty.span, format!("found value name used \ - as a type: {:?}", + as a type: {}", a_def).as_slice()); } } diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 18e2e6c4f09..9463bafc9d2 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -442,8 +442,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { fcx.infcx().resolve_type_vars_if_possible(fcx.expr_ty(&**begin)); let e_ty = fcx.infcx().resolve_type_vars_if_possible(fcx.expr_ty(&**end)); - debug!("pat_range beginning type: {:?}", b_ty); - debug!("pat_range ending type: {:?}", e_ty); + debug!("pat_range beginning type: {}", b_ty); + debug!("pat_range ending type: {}", e_ty); if !require_same_types( tcx, Some(fcx.infcx()), false, pat.span, b_ty, e_ty, || "mismatched types in range".to_string()) diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 45658e8a356..c2e7be2781f 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -643,7 +643,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { rcvr_ty: ty::t, restrict_to: Option<DefId>, param_ty: ParamTy) { - debug!("push_inherent_candidates_from_param(param_ty={:?})", + debug!("push_inherent_candidates_from_param(param_ty={})", param_ty); self.push_inherent_candidates_from_bounds( rcvr_ty, @@ -754,7 +754,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { } } None => { - debug!("trait doesn't contain method: {:?}", + debug!("trait doesn't contain method: {}", bound_trait_ref.def_id); // check next trait or bound } @@ -873,7 +873,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { None => None, Some(method) => { debug!("(searching for autoderef'd method) writing \ - adjustment {:?} for {}", adjustment, self.ty_to_string(self_ty)); + adjustment {} for {}", adjustment, self.ty_to_string(self_ty)); match adjustment { Some((self_expr_id, adj)) => { self.fcx.write_adjustment(self_expr_id, self.span, adj); @@ -1759,7 +1759,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { impl Repr for Candidate { fn repr(&self, tcx: &ty::ctxt) -> String { format!("Candidate(rcvr_ty={}, rcvr_substs={}, method_ty={}, \ - origin={:?})", + origin={})", self.rcvr_match_condition.repr(tcx), self.rcvr_substs.repr(tcx), self.method_ty.repr(tcx), diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 905d70eac19..c8318825e70 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1563,7 +1563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None => { self.tcx().sess.span_bug( span, - format!("no type for local variable {:?}", + format!("no type for local variable {}", nid).as_slice()); } } @@ -1622,7 +1622,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { node_id: ast::NodeId, span: Span, adj: ty::AutoAdjustment) { - debug!("write_adjustment(node_id={:?}, adj={:?})", node_id, adj); + debug!("write_adjustment(node_id={}, adj={})", node_id, adj); // Careful: adjustments can imply trait obligations if we are // casting from a concrete type to an object type. I think @@ -1673,7 +1673,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn register_unsize_obligations(&self, span: Span, unsize: &ty::UnsizeKind) { - debug!("register_unsize_obligations: unsize={:?}", unsize); + debug!("register_unsize_obligations: unsize={}", unsize); match *unsize { ty::UnsizeLength(..) => {} @@ -2551,7 +2551,7 @@ fn check_argument_types<'a>(fcx: &FnCtxt, err_args(supplied_arg_count) }; - debug!("check_argument_types: formal_tys={:?}", + debug!("check_argument_types: formal_tys={}", formal_tys.iter().map(|t| fcx.infcx().ty_to_string(*t)).collect::<Vec<String>>()); // Check the arguments. diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index f533079be69..b810ea3d94d 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -239,7 +239,7 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region { } } _ => { - tcx.sess.bug(format!("unexpected def in region_of_def: {:?}", + tcx.sess.bug(format!("unexpected def in region_of_def: {}", def).as_slice()) } } @@ -560,7 +560,7 @@ fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { } fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { - debug!("regionck::visit_expr(e={}, repeating_scope={:?})", + debug!("regionck::visit_expr(e={}, repeating_scope={})", expr.repr(rcx.fcx.tcx()), rcx.repeating_scope); // No matter what, the type of each expression must outlive the @@ -575,7 +575,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { // Check any autoderefs or autorefs that appear. for &adjustment in rcx.fcx.inh.adjustments.borrow().find(&expr.id).iter() { - debug!("adjustment={:?}", adjustment); + debug!("adjustment={}", adjustment); match *adjustment { ty::AdjustDerefRef(ty::AutoDerefRef {autoderefs, autoref: ref opt_autoref}) => { let expr_ty = rcx.resolve_node_type(expr.id); @@ -978,7 +978,7 @@ fn check_expr_fn_block(rcx: &mut Rcx, debug!("constrain_free_variables({}, {})", region_bound.repr(tcx), expr.repr(tcx)); for freevar in freevars.iter() { - debug!("freevar def is {:?}", freevar.def); + debug!("freevar def is {}", freevar.def); // Identify the variable being closed over and its node-id. let def = freevar.def; @@ -1116,7 +1116,7 @@ fn constrain_call<'a, I: Iterator<&'a ast::Expr>>(rcx: &mut Rcx, let tcx = rcx.fcx.tcx(); debug!("constrain_call(call_expr={}, \ receiver={}, \ - implicitly_ref_args={:?})", + implicitly_ref_args={})", call_expr.repr(tcx), receiver.repr(tcx), implicitly_ref_args); @@ -1171,7 +1171,7 @@ fn constrain_autoderefs(rcx: &mut Rcx, */ let r_deref_expr = ty::ReScope(deref_expr.id); for i in range(0u, derefs) { - debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={:?}/{:?}", + debug!("constrain_autoderefs(deref_expr=?, derefd_ty={}, derefs={}/{}", rcx.fcx.infcx().ty_to_string(derefd_ty), i, derefs); @@ -1280,7 +1280,7 @@ fn type_of_node_must_outlive( rcx.fcx.inh.adjustments.borrow().find(&id), |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ - ty={}, ty0={}, id={}, minimum_lifetime={:?})", + ty={}, ty0={}, id={}, minimum_lifetime={})", ty_to_string(tcx, ty), ty_to_string(tcx, ty0), id, minimum_lifetime); type_must_outlive(rcx, origin, ty, minimum_lifetime); @@ -1381,7 +1381,7 @@ fn link_autoref(rcx: &Rcx, * to lifetimes in the value being autoref'd. */ - debug!("link_autoref(autoref={:?})", autoref); + debug!("link_autoref(autoref={})", autoref); let mc = mc::MemCategorizationContext::new(rcx); let expr_cmt = ignore_err!(mc.cat_expr_autoderefd(expr, autoderefs)); debug!("expr_cmt={}", expr_cmt.repr(rcx.tcx())); @@ -1779,7 +1779,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx, * this function. */ - debug!("link_upvar_borrow_kind: inner_upvar_id={:?} outer_upvar_id={:?}", + debug!("link_upvar_borrow_kind: inner_upvar_id={} outer_upvar_id={}", inner_upvar_id, outer_upvar_id); let mut upvar_borrow_map = rcx.fcx.inh.upvar_borrow_map.borrow_mut(); @@ -1795,7 +1795,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx, fn adjust_upvar_borrow_kind_for_loan(upvar_id: ty::UpvarId, upvar_borrow: &mut ty::UpvarBorrow, kind: ty::BorrowKind) { - debug!("adjust_upvar_borrow_kind_for_loan: upvar_id={:?} kind={:?} -> {:?}", + debug!("adjust_upvar_borrow_kind_for_loan: upvar_id={} kind={} -> {}", upvar_id, upvar_borrow.kind, kind); adjust_upvar_borrow_kind(upvar_id, upvar_borrow, kind) @@ -1812,7 +1812,7 @@ fn adjust_upvar_borrow_kind(upvar_id: ty::UpvarId, * is required by some particular use. */ - debug!("adjust_upvar_borrow_kind: id={:?} kind=({:?} -> {:?})", + debug!("adjust_upvar_borrow_kind: id={} kind=({} -> {})", upvar_id, upvar_borrow.kind, kind); match (upvar_borrow.kind, kind) { diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 6384c655911..56dec61d410 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -306,7 +306,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { }) } }; - debug!("Adjustments for node {}: {:?}", id, resolved_adjustment); + debug!("Adjustments for node {}: {}", id, resolved_adjustment); self.tcx().adjustments.borrow_mut().insert( id, resolved_adjustment); } @@ -319,7 +319,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // Resolve any method map entry match self.fcx.inh.method_map.borrow_mut().pop(&method_call) { Some(method) => { - debug!("writeback::resolve_method_map_entry(call={:?}, entry={})", + debug!("writeback::resolve_method_map_entry(call={}, entry={})", method_call, method.repr(self.tcx())); let new_method = MethodCallee { diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index f6ac0e1666c..eef466ceebb 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -86,7 +86,7 @@ fn get_base_type(inference_context: &InferCtxt, ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) | ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { - debug!("(getting base type) no base type; found {:?}", + debug!("(getting base type) no base type; found {}", get(original_type).sty); None } @@ -245,7 +245,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { trait_ref: &ty::TraitRef, all_impl_items: &mut Vec<ImplOrTraitItemId>) { let tcx = self.crate_context.tcx; - debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})", + debug!("instantiate_default_methods(impl_id={}, trait_ref={})", impl_id, trait_ref.repr(tcx)); let impl_poly_type = ty::lookup_item_type(tcx, impl_id); @@ -256,7 +256,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let new_id = tcx.sess.next_node_id(); let new_did = local_def(new_id); - debug!("new_did={:?} trait_method={}", new_did, trait_method.repr(tcx)); + debug!("new_did={} trait_method={}", new_did, trait_method.repr(tcx)); // Create substitutions for the various trait parameters. let new_method_ty = diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 6e25b23daac..8e4948bbea9 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -171,7 +171,7 @@ impl<'a, 'tcx> AstConv<'tcx> for CrateCtxt<'a, 'tcx> { } x => { self.tcx.sess.bug(format!("unexpected sort of node \ - in get_item_ty(): {:?}", + in get_item_ty(): {}", x).as_slice()); } } @@ -1421,7 +1421,7 @@ pub fn trait_def_of_item(ccx: &CrateCtxt, it: &ast::Item) -> Rc<ty::TraitDef> { ref s => { tcx.sess.span_bug( it.span, - format!("trait_def_of_item invoked on {:?}", s).as_slice()); + format!("trait_def_of_item invoked on {}", s).as_slice()); } }; diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index a0c190c5c81..9f88bec7f42 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -231,7 +231,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { self.get_ref().infcx.tcx.sess.span_bug( self.get_ref().trace.origin.span(), format!("failed to resolve even without \ - any force options: {:?}", e).as_slice()); + any force options: {}", e).as_slice()); } } } @@ -243,7 +243,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_borrowed_pointer(a={}, sty_a={:?}, b={})", + debug!("coerce_borrowed_pointer(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -283,7 +283,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_unsized_with_borrow(a={}, sty_a={:?}, b={})", + debug!("coerce_unsized_with_borrow(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -314,7 +314,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, b: ty::t) -> CoerceResult { - debug!("coerce_unsized(a={}, sty_a={:?}, b={})", + debug!("coerce_unsized(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -342,7 +342,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::mt{ty: ty, mutbl: mt_b.mutbl}); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoPtr(AutoUnsize({:?})))", kind); + AutoPtr(AutoUnsize({})))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoPtr(r_borrow, mt_b.mutbl, @@ -365,7 +365,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { ty::mt{ty: ty, mutbl: mt_b.mutbl}); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoPtr(AutoUnsize({:?})))", kind); + AutoPtr(AutoUnsize({})))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoUnsafe(mt_b.mutbl, @@ -383,7 +383,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let ty = ty::mk_uniq(self.get_ref().infcx.tcx, ty); try!(self.get_ref().infcx.try(|| sub.tys(ty, b))); debug!("Success, coerced with AutoDerefRef(1, \ - AutoUnsizeUniq({:?}))", kind); + AutoUnsizeUniq({}))", kind); Ok(Some(AdjustDerefRef(AutoDerefRef { autoderefs: 1, autoref: Some(ty::AutoUnsizeUniq(kind)) @@ -405,7 +405,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, ty_b: ty::t) -> Option<(ty::t, ty::UnsizeKind)> { - debug!("unsize_ty(sty_a={:?}, ty_b={})", sty_a, ty_b.repr(self.get_ref().infcx.tcx)); + debug!("unsize_ty(sty_a={}, ty_b={})", sty_a, ty_b.repr(self.get_ref().infcx.tcx)); let tcx = self.get_ref().infcx.tcx; @@ -485,7 +485,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { { let tcx = self.get_ref().infcx.tcx; - debug!("coerce_borrowed_object(a={}, sty_a={:?}, b={}, b_mutbl={})", + debug!("coerce_borrowed_object(a={}, sty_a={}, b={}, b_mutbl={})", a.repr(tcx), sty_a, b.repr(tcx), b_mutbl); @@ -505,7 +505,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { { let tcx = self.get_ref().infcx.tcx; - debug!("coerce_unsafe_object(a={}, sty_a={:?}, b={}, b_mutbl={})", + debug!("coerce_unsafe_object(a={}, sty_a={}, b={}, b_mutbl={})", a.repr(tcx), sty_a, b.repr(tcx), b_mutbl); @@ -557,7 +557,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { sty_a: &ty::sty, b: ty::t) -> CoerceResult { - debug!("coerce_borrowed_fn(a={}, sty_a={:?}, b={})", + debug!("coerce_borrowed_fn(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); @@ -610,7 +610,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: ty::t, mutbl_b: ast::Mutability) -> CoerceResult { - debug!("coerce_unsafe_ptr(a={}, sty_a={:?}, b={})", + debug!("coerce_unsafe_ptr(a={}, sty_a={}, b={})", a.repr(self.get_ref().infcx.tcx), sty_a, b.repr(self.get_ref().infcx.tcx)); diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index a742cf45059..8ae0b603e48 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -390,7 +390,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t let tcx = this.infcx().tcx; let a_sty = &ty::get(a).sty; let b_sty = &ty::get(b).sty; - debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty); + debug!("super_tys: a_sty={} b_sty={}", a_sty, b_sty); return match (a_sty, b_sty) { // The "subtype" ought to be handling cases involving bot or var: (&ty::ty_bot, _) | @@ -470,7 +470,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t (&ty::ty_trait(ref a_), &ty::ty_trait(ref b_)) if a_.def_id == b_.def_id => { - debug!("Trying to match traits {:?} and {:?}", a, b); + debug!("Trying to match traits {} and {}", a, b); let substs = try!(this.substs(a_.def_id, &a_.substs, &b_.substs)); let bounds = try!(this.existential_bounds(a_.bounds, b_.bounds)); Ok(ty::mk_trait(tcx, diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 1a79837c03a..2ab585f5ae9 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -268,7 +268,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { } } let pe = ProcessedErrors(var_origins, trace_origins, same_regions); - debug!("errors processed: {:?}", pe); + debug!("errors processed: {}", pe); processed_errors.push(pe); } return processed_errors; @@ -297,7 +297,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { sub: Region, sup: Region) -> Option<FreeRegionsFromSameFn> { - debug!("free_regions_from_same_fn(sub={:?}, sup={:?})", sub, sup); + debug!("free_regions_from_same_fn(sub={}, sup={})", sub, sup); let (scope_id, fr1, fr2) = match (sub, sup) { (ReFree(fr1), ReFree(fr2)) => { if fr1.scope_id != fr2.scope_id { diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index 08d4f9f3a86..83ca67f33bc 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -109,7 +109,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { } fn regions(&self, a: ty::Region, b: ty::Region) -> cres<ty::Region> { - debug!("{}.regions({:?}, {:?})", + debug!("{}.regions({}, {})", self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); @@ -130,7 +130,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { // Note: this is a subtle algorithm. For a full explanation, // please see the large comment in `region_inference.rs`. - debug!("{}.fn_sigs({:?}, {:?})", + debug!("{}.fn_sigs({}, {})", self.tag(), a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); let _indenter = indenter(); @@ -254,7 +254,7 @@ impl<'f, 'tcx> Combine<'tcx> for Glb<'f, 'tcx> { } this.fields.infcx.tcx.sess.span_bug( this.fields.trace.origin.span(), - format!("could not find original bound region for {:?}", + format!("could not find original bound region for {}", r).as_slice()) } diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 6095e5b0504..24642d52138 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -123,7 +123,7 @@ pub fn var_ids<'tcx, T: Combine<'tcx>>(this: &T, r => { this.infcx().tcx.sess.span_bug( this.trace().origin.span(), - format!("found non-region-vid: {:?}", r).as_slice()); + format!("found non-region-vid: {}", r).as_slice()); } }).collect() } diff --git a/src/librustc/middle/typeck/infer/lub.rs b/src/librustc/middle/typeck/infer/lub.rs index 276a2264837..f2d9203f843 100644 --- a/src/librustc/middle/typeck/infer/lub.rs +++ b/src/librustc/middle/typeck/infer/lub.rs @@ -157,7 +157,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // Regions that pre-dated the LUB computation stay as they are. if !is_var_in_set(new_vars, r0) { assert!(!r0.is_bound()); - debug!("generalize_region(r0={:?}): not new variable", r0); + debug!("generalize_region(r0={}): not new variable", r0); return r0; } @@ -167,8 +167,8 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // *related* to regions that pre-date the LUB computation // stay as they are. if !tainted.iter().all(|r| is_var_in_set(new_vars, *r)) { - debug!("generalize_region(r0={:?}): \ - non-new-variables found in {:?}", + debug!("generalize_region(r0={}): \ + non-new-variables found in {}", r0, tainted); assert!(!r0.is_bound()); return r0; @@ -181,8 +181,8 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { // with. for (a_br, a_r) in a_map.iter() { if tainted.iter().any(|x| x == a_r) { - debug!("generalize_region(r0={:?}): \ - replacing with {:?}, tainted={:?}", + debug!("generalize_region(r0={}): \ + replacing with {}, tainted={}", r0, *a_br, tainted); return ty::ReLateBound(new_scope, *a_br); } @@ -190,7 +190,7 @@ impl<'f, 'tcx> Combine<'tcx> for Lub<'f, 'tcx> { this.fields.infcx.tcx.sess.span_bug( this.fields.trace.origin.span(), - format!("region {:?} is not associated with \ + format!("region {} is not associated with \ any bound region from A!", r0).as_slice()) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 7c04b371aae..7c455b85707 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -95,7 +95,7 @@ pub struct InferCtxt<'a, 'tcx: 'a> { /// Why did we require that the two types be related? /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum TypeOrigin { // Not yet categorized in a better way Misc(Span), @@ -127,7 +127,7 @@ pub enum TypeOrigin { } /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum ValuePairs { Types(ty::expected_found<ty::t>), TraitRefs(ty::expected_found<Rc<ty::TraitRef>>), @@ -137,7 +137,7 @@ pub enum ValuePairs { /// encounter an error or subtyping constraint. /// /// See `error_reporting.rs` for more details. -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct TypeTrace { origin: TypeOrigin, values: ValuePairs, @@ -146,7 +146,7 @@ pub struct TypeTrace { /// The origin of a `r1 <= r2` constraint. /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum SubregionOrigin { // Arose from a subtyping relation Subtype(TypeTrace), @@ -224,7 +224,7 @@ pub enum SubregionOrigin { /// Reasons to create a region inference variable /// /// See `error_reporting.rs` for more details -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum RegionVariableOrigin { // Region variables created for ill-categorized reasons, // mostly indicates places in need of refactoring @@ -887,7 +887,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { expected_ty: Option<ty::t>, actual_ty: String, err: Option<&ty::type_err>) { - debug!("hi! expected_ty = {:?}, actual_ty = {}", expected_ty, actual_ty); + debug!("hi! expected_ty = {}, actual_ty = {}", expected_ty, actual_ty); let error_str = err.map_or("".to_string(), |t_err| { format!(" ({})", ty::type_err_to_str(self.tcx, t_err)) @@ -965,7 +965,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { replace_late_bound_regions_in_fn_sig(self.tcx, fsig, |br| { let rvar = self.next_region_var( BoundRegionInFnType(trace.origin.span(), br)); - debug!("Bound region {} maps to {:?}", + debug!("Bound region {} maps to {}", bound_region_to_string(self.tcx, "", false, br), rvar); rvar @@ -1120,7 +1120,7 @@ impl Repr for SubregionOrigin { } Reborrow(a) => format!("Reborrow({})", a.repr(tcx)), ReborrowUpvar(a, b) => { - format!("ReborrowUpvar({},{:?})", a.repr(tcx), b) + format!("ReborrowUpvar({},{})", a.repr(tcx), b) } ReferenceOutlivesReferent(_, a) => { format!("ReferenceOutlivesReferent({})", a.repr(tcx)) diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 008ca6c0771..504550f0d40 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -81,7 +81,7 @@ pub enum CombineMapType { Lub, Glb } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum RegionResolutionError { /// `ConcreteFailure(o, a, b)`: /// @@ -133,7 +133,7 @@ pub enum RegionResolutionError { /// ``` /// would report an error because we expect 'a and 'b to match, and so we group /// 'a and 'b together inside a SameRegions struct -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct SameRegions { pub scope_id: ast::NodeId, pub regions: Vec<BoundRegion> diff --git a/src/librustc/middle/typeck/infer/sub.rs b/src/librustc/middle/typeck/infer/sub.rs index 7403d50a210..158fda802ff 100644 --- a/src/librustc/middle/typeck/infer/sub.rs +++ b/src/librustc/middle/typeck/infer/sub.rs @@ -200,7 +200,7 @@ impl<'f, 'tcx> Combine<'tcx> for Sub<'f, 'tcx> { let (skol_map, b_sig) = { replace_late_bound_regions_in_fn_sig(self.fields.infcx.tcx, b, |br| { let skol = self.fields.infcx.region_vars.new_skolemized(br); - debug!("Bound region {} skolemized to {:?}", + debug!("Bound region {} skolemized to {}", bound_region_to_string(self.fields.infcx.tcx, "", false, br), skol); skol diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 6ef2143b624..baa4f6d013b 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -315,7 +315,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_lub_ty(&self, t1: ty::t, t2: ty::t) -> ty::t { match self.lub().tys(t1, t2) { Ok(t) => t, - Err(ref e) => fail!("unexpected error computing LUB: {:?}", + Err(ref e) => fail!("unexpected error computing LUB: {}", ty::type_err_to_str(self.infcx.tcx, e)) } } @@ -341,7 +341,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.ty_to_string(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - fail!("unexpected error computing LUB: {:?}", e) + fail!("unexpected error computing LUB: {}", e) } Ok(t) => { self.assert_eq(t, t_glb); diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index e93ad056051..5a23d54c972 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -87,13 +87,13 @@ pub mod collect; pub mod coherence; pub mod variance; -#[deriving(Clone, Encodable, Decodable, PartialEq, PartialOrd)] +#[deriving(Clone, Encodable, Decodable, PartialEq, PartialOrd, Show)] pub struct param_index { pub space: subst::ParamSpace, pub index: uint } -#[deriving(Clone)] +#[deriving(Clone, Show)] pub enum MethodOrigin { // fully statically resolved method MethodStatic(ast::DefId), @@ -111,7 +111,7 @@ pub enum MethodOrigin { // details for a method invoked with a receiver whose type is a type parameter // with a bounded trait. -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct MethodParam { // the precise trait reference that occurs as a bound -- this may // be a supertrait of what the user actually typed. @@ -122,7 +122,7 @@ pub struct MethodParam { } // details for a method invoked with a receiver whose type is an object -#[deriving(Clone)] +#[deriving(Clone, Show)] pub struct MethodObject { // the (super)trait containing the method to be invoked pub trait_ref: Rc<ty::TraitRef>, @@ -249,7 +249,7 @@ impl Repr for vtable_origin { fn repr(&self, tcx: &ty::ctxt) -> String { match *self { vtable_static(def_id, ref tys, ref vtable_res) => { - format!("vtable_static({:?}:{}, {}, {})", + format!("vtable_static({}:{}, {}, {})", def_id, ty::item_path_str(tcx, def_id), tys.repr(tcx), @@ -257,7 +257,7 @@ impl Repr for vtable_origin { } vtable_param(x, y) => { - format!("vtable_param({:?}, {:?})", x, y) + format!("vtable_param({}, {})", x, y) } vtable_unboxed_closure(def_id) => { diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index 60a7aa77904..dd6e087b672 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -232,6 +232,7 @@ pub fn infer_variance(tcx: &ty::ctxt) { type VarianceTermPtr<'a> = &'a VarianceTerm<'a>; +#[deriving(Show)] struct InferredIndex(uint); enum VarianceTerm<'a> { @@ -325,10 +326,10 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { assert!(newly_added); debug!("add_inferred(item_id={}, \ - kind={:?}, \ + kind={}, \ index={}, \ param_id={}, - inf_index={:?})", + inf_index={})", item_id, kind, index, param_id, inf_index); } @@ -852,7 +853,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { region_param_defs: &[ty::RegionParameterDef], substs: &subst::Substs, variance: VarianceTermPtr<'a>) { - debug!("add_constraints_from_substs(def_id={:?})", def_id); + debug!("add_constraints_from_substs(def_id={})", def_id); for p in type_param_defs.iter() { let variance_decl = diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 8ea9015c05d..082dde978d8 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -13,6 +13,7 @@ use std::cell::RefCell; use std::collections::HashMap; use std::hash::{Hash, Hasher}; +use std::fmt::Show; use syntax::ast; use syntax::visit; use syntax::visit::Visitor; @@ -36,12 +37,12 @@ pub fn time<T, U>(do_it: bool, what: &str, u: U, f: |U| -> T) -> T { rv } -pub fn indent<R>(op: || -> R) -> R { +pub fn indent<R: Show>(op: || -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` // to make debug output more readable. debug!(">>"); let r = op(); - debug!("<< (Result = {:?})", r); + debug!("<< (Result = {})", r); r } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 459e7eb093e..404864cec04 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -154,7 +154,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) // I believe these cases should not occur (except when debugging, // perhaps) ty::ReInfer(_) | ty::ReLateBound(..) => { - (format!("lifetime {:?}", region), None) + (format!("lifetime {}", region), None) } }; @@ -599,7 +599,7 @@ impl<T:UserString> UserString for Vec<T> { impl Repr for def::Def { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -843,14 +843,14 @@ impl Repr for ast::DefId { Some(ast_map::NodeVariant(..)) | Some(ast_map::NodeStructCtor(..)) => { return format!( - "{:?}:{}", + "{}:{}", *self, ty::item_path_str(tcx, *self)) } _ => {} } } - return format!("{:?}", *self) + return format!("{}", *self) } } @@ -922,19 +922,19 @@ impl Repr for ast::Ident { impl Repr for ast::ExplicitSelf_ { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::Visibility { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ty::BareFnTy { fn repr(&self, tcx: &ctxt) -> String { - format!("BareFnTy {{fn_style: {:?}, abi: {}, sig: {}}}", + format!("BareFnTy {{fn_style: {}, abi: {}, sig: {}}}", self.fn_style, self.abi.to_string(), self.sig.repr(tcx)) @@ -985,7 +985,7 @@ impl Repr for typeck::MethodParam { impl Repr for typeck::MethodObject { fn repr(&self, tcx: &ctxt) -> String { - format!("MethodObject({},{:?},{:?})", + format!("MethodObject({},{},{})", self.trait_ref.repr(tcx), self.method_num, self.real_index) @@ -1000,7 +1000,7 @@ impl Repr for ty::TraitStore { impl Repr for ty::BuiltinBound { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -1118,13 +1118,13 @@ impl Repr for ty::UpvarId { impl Repr for ast::Mutability { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ty::BorrowKind { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } @@ -1162,25 +1162,25 @@ impl Repr for ty::TyVid { impl Repr for ty::IntVarValue { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::IntTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::UintTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } impl Repr for ast::FloatTy { fn repr(&self, _tcx: &ctxt) -> String { - format!("{:?}", *self) + format!("{}", *self) } } |
