mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Merge pull request #528 from marcusklaas/chain-idempotence
Restore idempotence for chain formatting
This commit is contained in:
commit
45bcf59bde
@ -80,11 +80,11 @@ pub fn rewrite_chain(mut expr: &ast::Expr,
|
|||||||
let veto_single_line = if context.config.take_source_hints && subexpr_list.len() > 1 {
|
let veto_single_line = if context.config.take_source_hints && subexpr_list.len() > 1 {
|
||||||
// Look at the source code. Unless all chain elements start on the same
|
// Look at the source code. Unless all chain elements start on the same
|
||||||
// line, we won't consider putting them on a single line either.
|
// line, we won't consider putting them on a single line either.
|
||||||
let first_line_no = context.codemap.lookup_char_pos(subexpr_list[0].span.lo).line;
|
let last_span = context.snippet(mk_sp(subexpr_list[1].span.hi, total_span.hi));
|
||||||
|
let first_span = context.snippet(subexpr_list[1].span);
|
||||||
|
let last_iter = last_span.chars().take_while(|c| c.is_whitespace());
|
||||||
|
|
||||||
subexpr_list[1..]
|
first_span.chars().chain(last_iter).any(|c| c == '\n')
|
||||||
.iter()
|
|
||||||
.any(|ex| context.codemap.lookup_char_pos(ex.span.hi).line != first_line_no)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
@ -101,3 +101,8 @@ fn floaters() {
|
|||||||
|
|
||||||
a + match x { true => "yay!", false => "boo!" }.bar()
|
a + match x { true => "yay!", false => "boo!" }.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_replaced_content() -> bool {
|
||||||
|
constellat.send(ConstellationMsg::ViewportConstrained(
|
||||||
|
self.id, constraints)).unwrap();
|
||||||
|
}
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
// Test chain formatting without overflowing the last item.
|
// Test chain formatting without overflowing the last item.
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd();
|
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
||||||
|
.ddddddddddddddddddddddddddd();
|
||||||
|
|
||||||
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
||||||
.ddddddddddddddddddddddddddd
|
.ddddddddddddddddddddddddddd
|
||||||
|
@ -7,7 +7,8 @@ fn main() {
|
|||||||
.1
|
.1
|
||||||
.foo(|x| x + 1);
|
.foo(|x| x + 1);
|
||||||
|
|
||||||
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc.ddddddddddddddddddddddddddd();
|
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
||||||
|
.ddddddddddddddddddddddddddd();
|
||||||
|
|
||||||
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
bbbbbbbbbbbbbbbbbbb.ccccccccccccccccccccccccccccccccccccc
|
||||||
.ddddddddddddddddddddddddddd
|
.ddddddddddddddddddddddddddd
|
||||||
@ -126,3 +127,8 @@ fn floaters() {
|
|||||||
}
|
}
|
||||||
.bar()
|
.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_replaced_content() -> bool {
|
||||||
|
constellat.send(ConstellationMsg::ViewportConstrained(self.id, constraints))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user