mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Reformatting after rebase
This commit is contained in:
parent
dcf9f61635
commit
df4fb8a05b
@ -302,7 +302,7 @@ trait ChainFormatter {
|
||||
// foo.bar
|
||||
// .baz()
|
||||
// ```
|
||||
// If `bar` were not part of the root, then baz would be orphaned and 'float'.
|
||||
// If `bar` were not part of the root, then foo would be orphaned and 'float'.
|
||||
fn format_root(
|
||||
&mut self,
|
||||
parent: &ChainItem,
|
||||
|
@ -376,7 +376,8 @@ where
|
||||
ast::ExprKind::Closure(..) => true,
|
||||
_ => false,
|
||||
}).unwrap_or(false)
|
||||
}).count() > 1
|
||||
}).count()
|
||||
> 1
|
||||
}
|
||||
|
||||
fn is_block_closure_forced(context: &RewriteContext, expr: &ast::Expr) -> bool {
|
||||
|
@ -246,8 +246,7 @@ impl FormattingError {
|
||||
fl.file
|
||||
.get_line(fl.lines[0].line_index)
|
||||
.map(|l| l.into_owned())
|
||||
})
|
||||
.unwrap_or_else(|| String::new()),
|
||||
}).unwrap_or_else(|| String::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1118,22 +1118,21 @@ fn indent_macro_snippet(
|
||||
}).min()?;
|
||||
|
||||
Some(
|
||||
first_line + "\n"
|
||||
+ &trimmed_lines
|
||||
.iter()
|
||||
.map(
|
||||
|&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
|
||||
_ if !trimmed => line.to_owned(),
|
||||
Some(original_indent_width) => {
|
||||
let new_indent_width = indent.width()
|
||||
+ original_indent_width.saturating_sub(min_prefix_space_width);
|
||||
let new_indent = Indent::from_width(context.config, new_indent_width);
|
||||
format!("{}{}", new_indent.to_string(context.config), line.trim())
|
||||
}
|
||||
None => String::new(),
|
||||
},
|
||||
).collect::<Vec<_>>()
|
||||
.join("\n"),
|
||||
first_line + "\n" + &trimmed_lines
|
||||
.iter()
|
||||
.map(
|
||||
|&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
|
||||
_ if !trimmed => line.to_owned(),
|
||||
Some(original_indent_width) => {
|
||||
let new_indent_width = indent.width() + original_indent_width
|
||||
.saturating_sub(min_prefix_space_width);
|
||||
let new_indent = Indent::from_width(context.config, new_indent_width);
|
||||
format!("{}{}", new_indent.to_string(context.config), line.trim())
|
||||
}
|
||||
None => String::new(),
|
||||
},
|
||||
).collect::<Vec<_>>()
|
||||
.join("\n"),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ fn rewrite_pairs_multiline<T: Rewrite>(
|
||||
IndentStyle::Visual => shape.visual_indent(0),
|
||||
IndentStyle::Block => shape.block_indent(context.config.tab_spaces()),
|
||||
}).with_max_width(&context.config)
|
||||
.sub_width(rhs_offset)?;
|
||||
.sub_width(rhs_offset)?;
|
||||
|
||||
let indent_str = nested_shape.indent.to_string_with_newline(context.config);
|
||||
let mut result = String::new();
|
||||
|
@ -241,12 +241,13 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
let item_length = items
|
||||
.iter()
|
||||
.take_while(|ppi| {
|
||||
item_kind.is_same_item_kind(&***ppi) && (!in_group || {
|
||||
let current = self.codemap.lookup_line_range(ppi.span());
|
||||
let in_same_group = current.lo < last.hi + 2;
|
||||
last = current;
|
||||
in_same_group
|
||||
})
|
||||
item_kind.is_same_item_kind(&***ppi)
|
||||
&& (!in_group || {
|
||||
let current = self.codemap.lookup_line_range(ppi.span());
|
||||
let in_same_group = current.lo < last.hi + 2;
|
||||
last = current;
|
||||
in_same_group
|
||||
})
|
||||
}).count();
|
||||
let items = &items[..item_length];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user