Some debugging stuff

This commit is contained in:
Nick Cameron 2017-01-27 09:14:26 +13:00
parent e56ef44a3a
commit 6054f28bd2
2 changed files with 4 additions and 1 deletions

View File

@ -694,6 +694,7 @@ impl Rewrite for ast::Stmt {
}
// Abstraction over control flow expressions
#[derive(Debug)]
struct ControlFlow<'a> {
cond: Option<&'a ast::Expr>,
block: &'a ast::Block,
@ -845,6 +846,7 @@ impl<'a> ControlFlow<'a> {
impl<'a> Rewrite for ControlFlow<'a> {
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
debug!("ControlFlow::rewrite {:?} {} {:?}", self, width, offset);
let (budget, indent) = if self.nested_if {
// We are part of an if-elseif-else chain. Our constraints are tightened.
// 7 = "} else " .len()

View File

@ -31,6 +31,7 @@ use syntax::ast::ImplItem;
// let pat: ty = init;
impl Rewrite for ast::Local {
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
debug!("Local::rewrite {:?} {} {:?}", self, width, offset);
let mut result = "let ".to_owned();
let pattern_offset = offset + result.len();
// 1 = ;
@ -64,9 +65,9 @@ impl Rewrite for ast::Local {
result.push_str(&infix);
if let Some(ref ex) = self.init {
// 1 = trailing semicolon;
let budget = try_opt!(width.checked_sub(context.block_indent.width() + 1));
// 1 = trailing semicolon;
result =
try_opt!(rewrite_assign_rhs(&context, result, ex, budget, context.block_indent));
}