From 11118dcf19a3c13c197345402a41c280bd329309 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 28 Sep 2017 13:39:43 -0400 Subject: [PATCH] add some better debugs --- src/librustc/infer/higher_ranked/mod.rs | 5 ++++- src/librustc_typeck/astconv.rs | 7 ++++++- src/librustc_typeck/check/closure.rs | 9 +++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 0d02420457e6..6736751a5a2c 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -155,7 +155,10 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { .filter(|&&r| !skol_resolution_map.contains_key(r)) .cloned() .next() - .expect("no representative region"); + .unwrap_or_else(|| { + bug!("no representative region for `{:?}` in `{:?}`", + skol, regions) + }); (skol, representative) }) diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index c7f7e62fd61e..7cc8e067132f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1226,7 +1226,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { None } }); - self.ty_of_arg(a, expected_arg_ty) + + let input_ty = self.ty_of_arg(a, expected_arg_ty); + debug!("ty_of_closure: i={} input_ty={:?} expected_arg_ty={:?}", + i, input_ty, expected_arg_ty); + + input_ty }); let expected_ret_ty = expected_sig.as_ref().map(|e| e.output()); diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 07159770d5ba..077050167db2 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -51,7 +51,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { body: &'gcx hir::Body, expected_sig: Option>) -> Ty<'tcx> { - debug!("check_closure opt_kind={:?} expected_sig={:?}", + debug!("check_closure(opt_kind={:?}, expected_sig={:?})", opt_kind, expected_sig); @@ -61,10 +61,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { decl, Abi::RustCall, expected_sig); + + debug!("check_closure: ty_of_closure returns {:?}", sig); + // `deduce_expectations_from_expected_type` introduces late-bound // lifetimes defined elsewhere, which we need to anonymize away. let sig = self.tcx.anonymize_late_bound_regions(&sig); + debug!("check_closure: anonymized sig={:?}", sig); + // Create type variables (for now) to represent the transformed // types of upvars. These will be unified during the upvar // inference phase (`upvar.rs`). @@ -104,7 +109,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { sig.abi )); - debug!("closure for {:?} --> sig={:?} opt_kind={:?}", + debug!("check_closure: expr_def_id={:?}, sig={:?}, opt_kind={:?}", expr_def_id, sig, opt_kind);