mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-12 20:16:49 +00:00
Fix offset for unary operations
Fixes https://github.com/nrc/rustfmt/issues/227.
This commit is contained in:
parent
2bf4d74832
commit
a896d91ff6
@ -1134,11 +1134,10 @@ fn rewrite_unary_op(context: &RewriteContext,
|
||||
ast::UnOp::UnNot => "!",
|
||||
ast::UnOp::UnNeg => "-",
|
||||
};
|
||||
let operator_len = operator_str.len();
|
||||
|
||||
let subexpr =
|
||||
try_opt!(expr.rewrite(context, try_opt!(width.checked_sub(operator_str.len())), offset));
|
||||
|
||||
Some(format!("{}{}", operator_str, subexpr))
|
||||
expr.rewrite(context, try_opt!(width.checked_sub(operator_len)), offset + operator_len)
|
||||
.map(|r| format!("{}{}", operator_str, r))
|
||||
}
|
||||
|
||||
fn rewrite_assignment(context: &RewriteContext,
|
||||
|
@ -105,3 +105,9 @@ fn qux() {
|
||||
// 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.
|
||||
}
|
||||
}
|
||||
|
||||
fn issue227() {
|
||||
{
|
||||
let handler = box DocumentProgressHandler::new(addr,
|
||||
DocumentProgressTask::DOMContentLoaded);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user