Fix offset for unary operations
Fixes https://github.com/nrc/rustfmt/issues/227.
This commit is contained in:
parent
2bf4d74832
commit
a896d91ff6
3 changed files with 16 additions and 4 deletions
|
@ -1134,11 +1134,10 @@ fn rewrite_unary_op(context: &RewriteContext,
|
||||||
ast::UnOp::UnNot => "!",
|
ast::UnOp::UnNot => "!",
|
||||||
ast::UnOp::UnNeg => "-",
|
ast::UnOp::UnNeg => "-",
|
||||||
};
|
};
|
||||||
|
let operator_len = operator_str.len();
|
||||||
|
|
||||||
let subexpr =
|
expr.rewrite(context, try_opt!(width.checked_sub(operator_len)), offset + operator_len)
|
||||||
try_opt!(expr.rewrite(context, try_opt!(width.checked_sub(operator_str.len())), offset));
|
.map(|r| format!("{}{}", operator_str, r))
|
||||||
|
|
||||||
Some(format!("{}{}", operator_str, subexpr))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rewrite_assignment(context: &RewriteContext,
|
fn rewrite_assignment(context: &RewriteContext,
|
||||||
|
|
|
@ -105,3 +105,9 @@ fn qux() {
|
||||||
// A block with a comment.
|
// A block with a comment.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue227() {
|
||||||
|
{
|
||||||
|
let handler = box DocumentProgressHandler::new(addr, DocumentProgressTask::DOMContentLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -139,3 +139,10 @@ fn qux() {
|
||||||
// A block with a comment.
|
// A block with a comment.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue227() {
|
||||||
|
{
|
||||||
|
let handler = box DocumentProgressHandler::new(addr,
|
||||||
|
DocumentProgressTask::DOMContentLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue