mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 19:53:46 +00:00
Rebasing
This commit is contained in:
parent
6f30d9e7c9
commit
18ccd0190e
@ -574,7 +574,8 @@ fn rewrite_method_call(
|
||||
let (lo, type_str) = if types.is_empty() {
|
||||
(args[0].span.hi, String::new())
|
||||
} else {
|
||||
let type_list: Vec<_> = try_opt!(types.iter().map(|ty| ty.rewrite(context, shape)).collect());
|
||||
let type_list: Vec<_> =
|
||||
try_opt!(types.iter().map(|ty| ty.rewrite(context, shape)).collect());
|
||||
|
||||
let type_str = if context.config.spaces_within_angle_brackets() && type_list.len() > 0 {
|
||||
format!("::< {} >", type_list.join(", "))
|
||||
|
144
src/expr.rs
144
src/expr.rs
@ -281,7 +281,9 @@ fn format_expr(
|
||||
Some(format!(
|
||||
"{}{}",
|
||||
"do catch ",
|
||||
try_opt!(block.rewrite(&context, Shape::legacy(budget, shape.indent)))
|
||||
try_opt!(
|
||||
block.rewrite(&context, Shape::legacy(budget, shape.indent))
|
||||
)
|
||||
))
|
||||
}
|
||||
};
|
||||
@ -1428,9 +1430,11 @@ impl Rewrite for ast::Arm {
|
||||
if contains_skip(attrs) {
|
||||
return None;
|
||||
}
|
||||
format!("{}\n{}",
|
||||
try_opt!(attrs.rewrite(context, shape)),
|
||||
shape.indent.to_string(context.config))
|
||||
format!(
|
||||
"{}\n{}",
|
||||
try_opt!(attrs.rewrite(context, shape)),
|
||||
shape.indent.to_string(context.config)
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
@ -1515,11 +1519,11 @@ impl Rewrite for ast::Arm {
|
||||
};
|
||||
|
||||
match rewrite {
|
||||
Some(ref body_str) if (!body_str.contains('\n') &&
|
||||
body_str.len() <= arm_shape.width) ||
|
||||
!context.config.wrap_match_arms() ||
|
||||
(extend && first_line_width(body_str) <= arm_shape.width) ||
|
||||
is_block => {
|
||||
Some(ref body_str)
|
||||
if (!body_str.contains('\n') && body_str.len() <= arm_shape.width) ||
|
||||
!context.config.wrap_match_arms() ||
|
||||
(extend && first_line_width(body_str) <= arm_shape.width) ||
|
||||
is_block => {
|
||||
let block_sep = match context.config.control_brace_style() {
|
||||
ControlBraceStyle::AlwaysNextLine if is_block => alt_block_sep.as_str(),
|
||||
_ => " ",
|
||||
@ -1610,28 +1614,33 @@ fn rewrite_guard(
|
||||
if let Some(ref guard) = *guard {
|
||||
// First try to fit the guard string on the same line as the pattern.
|
||||
// 4 = ` if `, 5 = ` => {`
|
||||
if let Some(cond_shape) = shape
|
||||
.shrink_left(pattern_width + 4)
|
||||
.and_then(|s| s.sub_width(5)) {
|
||||
if let Some(cond_str) = guard
|
||||
.rewrite(context, cond_shape)
|
||||
.and_then(|s| s.rewrite(context, cond_shape)) {
|
||||
if let Some(cond_shape) = shape.shrink_left(pattern_width + 4).and_then(
|
||||
|s| s.sub_width(5),
|
||||
)
|
||||
{
|
||||
if let Some(cond_str) = guard.rewrite(context, cond_shape).and_then(|s| {
|
||||
s.rewrite(context, cond_shape)
|
||||
})
|
||||
{
|
||||
return Some(format!(" if {}", cond_str));
|
||||
}
|
||||
}
|
||||
|
||||
// Not enough space to put the guard after the pattern, try a newline.
|
||||
// 3 == `if `
|
||||
if let Some(cond_shape) = Shape::indented(shape.indent.block_indent(context.config) + 3,
|
||||
context.config)
|
||||
.sub_width(3) {
|
||||
if let Some(cond_shape) = Shape::indented(
|
||||
shape.indent.block_indent(context.config) + 3,
|
||||
context.config,
|
||||
).sub_width(3)
|
||||
{
|
||||
if let Some(cond_str) = guard.rewrite(context, cond_shape) {
|
||||
return Some(format!("\n{}if {}",
|
||||
shape
|
||||
.indent
|
||||
.block_indent(context.config)
|
||||
.to_string(context.config),
|
||||
cond_str));
|
||||
return Some(format!(
|
||||
"\n{}if {}",
|
||||
shape.indent.block_indent(context.config).to_string(
|
||||
context.config,
|
||||
),
|
||||
cond_str
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1826,26 +1835,28 @@ fn rewrite_call_inner(
|
||||
let span_lo = context.codemap.span_after(span, "(");
|
||||
let args_span = mk_sp(span_lo, span.hi);
|
||||
|
||||
let (extendable, list_str) = rewrite_call_args(context,
|
||||
args,
|
||||
args_span,
|
||||
nested_shape,
|
||||
one_line_width,
|
||||
force_trailing_comma)
|
||||
.or_else(|| if context.use_block_indent() {
|
||||
rewrite_call_args(context,
|
||||
args,
|
||||
args_span,
|
||||
Shape::indented(shape
|
||||
.block()
|
||||
.indent
|
||||
.block_indent(context.config),
|
||||
context.config),
|
||||
0,
|
||||
force_trailing_comma)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
let (extendable, list_str) = rewrite_call_args(
|
||||
context,
|
||||
args,
|
||||
args_span,
|
||||
nested_shape,
|
||||
one_line_width,
|
||||
force_trailing_comma,
|
||||
).or_else(|| if context.use_block_indent() {
|
||||
rewrite_call_args(
|
||||
context,
|
||||
args,
|
||||
args_span,
|
||||
Shape::indented(
|
||||
shape.block().indent.block_indent(context.config),
|
||||
context.config,
|
||||
),
|
||||
0,
|
||||
force_trailing_comma,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.ok_or(Ordering::Less)?;
|
||||
|
||||
if !context.use_block_indent() && need_block_indent(&list_str, nested_shape) && !extendable {
|
||||
@ -1861,12 +1872,20 @@ fn rewrite_call_inner(
|
||||
);
|
||||
}
|
||||
|
||||
let args_shape = shape
|
||||
.sub_width(last_line_width(&callee_str))
|
||||
.ok_or(Ordering::Less)?;
|
||||
Ok(format!("{}{}",
|
||||
callee_str,
|
||||
wrap_args_with_parens(context, &list_str, extendable, args_shape, nested_shape)))
|
||||
let args_shape = shape.sub_width(last_line_width(&callee_str)).ok_or(
|
||||
Ordering::Less,
|
||||
)?;
|
||||
Ok(format!(
|
||||
"{}{}",
|
||||
callee_str,
|
||||
wrap_args_with_parens(
|
||||
context,
|
||||
&list_str,
|
||||
extendable,
|
||||
args_shape,
|
||||
nested_shape,
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
fn need_block_indent(s: &str, shape: Shape) -> bool {
|
||||
@ -2056,15 +2075,17 @@ fn paren_overhead(context: &RewriteContext) -> usize {
|
||||
}
|
||||
}
|
||||
|
||||
fn wrap_args_with_parens(context: &RewriteContext,
|
||||
args_str: &str,
|
||||
is_extendable: bool,
|
||||
shape: Shape,
|
||||
nested_shape: Shape)
|
||||
-> String {
|
||||
fn wrap_args_with_parens(
|
||||
context: &RewriteContext,
|
||||
args_str: &str,
|
||||
is_extendable: bool,
|
||||
shape: Shape,
|
||||
nested_shape: Shape,
|
||||
) -> String {
|
||||
if !context.use_block_indent() ||
|
||||
(context.inside_macro && !args_str.contains('\n') &&
|
||||
args_str.len() + paren_overhead(context) <= shape.width) || is_extendable {
|
||||
(context.inside_macro && !args_str.contains('\n') &&
|
||||
args_str.len() + paren_overhead(context) <= shape.width) || is_extendable
|
||||
{
|
||||
if context.config.spaces_within_parens() && args_str.len() > 0 {
|
||||
format!("( {} )", args_str)
|
||||
} else {
|
||||
@ -2166,10 +2187,9 @@ fn rewrite_struct_lit<'a>(
|
||||
return Some(format!("{} {{}}", path_str));
|
||||
}
|
||||
|
||||
let field_iter = fields
|
||||
.into_iter()
|
||||
.map(StructLitField::Regular)
|
||||
.chain(base.into_iter().map(StructLitField::Base));
|
||||
let field_iter = fields.into_iter().map(StructLitField::Regular).chain(
|
||||
base.into_iter().map(StructLitField::Base),
|
||||
);
|
||||
|
||||
// Foo { a: Foo } - indent is +3, width is -5.
|
||||
let (h_shape, v_shape) = try_opt!(struct_lit_shape(shape, context, path_str.len() + 3, 2));
|
||||
|
321
src/items.rs
321
src/items.rs
@ -550,11 +550,12 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_impl(context: &RewriteContext,
|
||||
item: &ast::Item,
|
||||
offset: Indent,
|
||||
where_span_end: Option<BytePos>)
|
||||
-> Option<String> {
|
||||
pub fn format_impl(
|
||||
context: &RewriteContext,
|
||||
item: &ast::Item,
|
||||
offset: Indent,
|
||||
where_span_end: Option<BytePos>,
|
||||
) -> Option<String> {
|
||||
if let ast::ItemKind::Impl(_, _, _, ref generics, _, _, ref items) = item.node {
|
||||
let mut result = String::new();
|
||||
let ref_and_type = try_opt!(format_impl_ref_and_type(context, item, offset));
|
||||
@ -569,18 +570,26 @@ pub fn format_impl(context: &RewriteContext,
|
||||
.checked_sub(last_line_width(&result))
|
||||
.unwrap_or(0)
|
||||
};
|
||||
let where_clause_str = try_opt!(rewrite_where_clause(context,
|
||||
&generics.where_clause,
|
||||
context.config.item_brace_style(),
|
||||
Shape::legacy(where_budget,
|
||||
offset.block_only()),
|
||||
context.config.where_density(),
|
||||
"{",
|
||||
false,
|
||||
last_line_width(&ref_and_type) == 1,
|
||||
where_span_end));
|
||||
let where_clause_str = try_opt!(rewrite_where_clause(
|
||||
context,
|
||||
&generics.where_clause,
|
||||
context.config.item_brace_style(),
|
||||
Shape::legacy(where_budget, offset.block_only()),
|
||||
context.config.where_density(),
|
||||
"{",
|
||||
false,
|
||||
last_line_width(&ref_and_type) == 1,
|
||||
where_span_end,
|
||||
));
|
||||
|
||||
if try_opt!(is_impl_single_line(context, &items, &result, &where_clause_str, &item)) {
|
||||
if try_opt!(is_impl_single_line(
|
||||
context,
|
||||
&items,
|
||||
&result,
|
||||
&where_clause_str,
|
||||
&item,
|
||||
))
|
||||
{
|
||||
result.push_str(&where_clause_str);
|
||||
if where_clause_str.contains('\n') {
|
||||
let white_space = offset.to_string(context.config);
|
||||
@ -670,10 +679,11 @@ fn is_impl_single_line(
|
||||
)
|
||||
}
|
||||
|
||||
fn format_impl_ref_and_type(context: &RewriteContext,
|
||||
item: &ast::Item,
|
||||
offset: Indent)
|
||||
-> Option<String> {
|
||||
fn format_impl_ref_and_type(
|
||||
context: &RewriteContext,
|
||||
item: &ast::Item,
|
||||
offset: Indent,
|
||||
) -> Option<String> {
|
||||
if let ast::ItemKind::Impl(unsafety,
|
||||
polarity,
|
||||
_,
|
||||
@ -693,12 +703,18 @@ fn format_impl_ref_and_type(context: &RewriteContext,
|
||||
Some(ref tr) => tr.path.span.lo,
|
||||
None => self_ty.span.lo,
|
||||
};
|
||||
let shape = generics_shape_from_config(context.config,
|
||||
Shape::indented(offset + last_line_width(&result),
|
||||
context.config),
|
||||
0);
|
||||
let generics_str =
|
||||
try_opt!(rewrite_generics_inner(context, generics, shape, shape.width, mk_sp(lo, hi)));
|
||||
let shape = generics_shape_from_config(
|
||||
context.config,
|
||||
Shape::indented(offset + last_line_width(&result), context.config),
|
||||
0,
|
||||
);
|
||||
let generics_str = try_opt!(rewrite_generics_inner(
|
||||
context,
|
||||
generics,
|
||||
shape,
|
||||
shape.width,
|
||||
mk_sp(lo, hi),
|
||||
));
|
||||
|
||||
let polarity_str = if polarity == ast::ImplPolarity::Negative {
|
||||
"!"
|
||||
@ -709,24 +725,34 @@ fn format_impl_ref_and_type(context: &RewriteContext,
|
||||
if let Some(ref trait_ref) = *trait_ref {
|
||||
let result_len = result.len();
|
||||
if let Some(trait_ref_str) =
|
||||
rewrite_trait_ref(context,
|
||||
&trait_ref,
|
||||
offset,
|
||||
&generics_str,
|
||||
true,
|
||||
polarity_str,
|
||||
result_len) {
|
||||
rewrite_trait_ref(
|
||||
context,
|
||||
&trait_ref,
|
||||
offset,
|
||||
&generics_str,
|
||||
true,
|
||||
polarity_str,
|
||||
result_len,
|
||||
)
|
||||
{
|
||||
result.push_str(&trait_ref_str);
|
||||
} else {
|
||||
let generics_str =
|
||||
try_opt!(rewrite_generics_inner(context, generics, shape, 0, mk_sp(lo, hi)));
|
||||
result.push_str(&try_opt!(rewrite_trait_ref(context,
|
||||
&trait_ref,
|
||||
offset,
|
||||
&generics_str,
|
||||
false,
|
||||
polarity_str,
|
||||
result_len)));
|
||||
let generics_str = try_opt!(rewrite_generics_inner(
|
||||
context,
|
||||
generics,
|
||||
shape,
|
||||
0,
|
||||
mk_sp(lo, hi),
|
||||
));
|
||||
result.push_str(&try_opt!(rewrite_trait_ref(
|
||||
context,
|
||||
&trait_ref,
|
||||
offset,
|
||||
&generics_str,
|
||||
false,
|
||||
polarity_str,
|
||||
result_len,
|
||||
)));
|
||||
}
|
||||
} else {
|
||||
result.push_str(&generics_str);
|
||||
@ -777,32 +803,41 @@ fn format_impl_ref_and_type(context: &RewriteContext,
|
||||
Style::Legacy => new_line_offset + trait_ref_overhead,
|
||||
Style::Rfc => new_line_offset,
|
||||
};
|
||||
result.push_str(&*try_opt!(self_ty.rewrite(context, Shape::legacy(budget, type_offset))));
|
||||
result.push_str(&*try_opt!(self_ty.rewrite(
|
||||
context,
|
||||
Shape::legacy(budget, type_offset),
|
||||
)));
|
||||
Some(result)
|
||||
} else {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
||||
fn rewrite_trait_ref(context: &RewriteContext,
|
||||
trait_ref: &ast::TraitRef,
|
||||
offset: Indent,
|
||||
generics_str: &str,
|
||||
retry: bool,
|
||||
polarity_str: &str,
|
||||
result_len: usize)
|
||||
-> Option<String> {
|
||||
fn rewrite_trait_ref(
|
||||
context: &RewriteContext,
|
||||
trait_ref: &ast::TraitRef,
|
||||
offset: Indent,
|
||||
generics_str: &str,
|
||||
retry: bool,
|
||||
polarity_str: &str,
|
||||
result_len: usize,
|
||||
) -> Option<String> {
|
||||
// 1 = space between generics and trait_ref
|
||||
let used_space = 1 + polarity_str.len() +
|
||||
if generics_str.contains('\n') {
|
||||
last_line_width(&generics_str)
|
||||
} else {
|
||||
result_len + generics_str.len()
|
||||
};
|
||||
if generics_str.contains('\n') {
|
||||
last_line_width(&generics_str)
|
||||
} else {
|
||||
result_len + generics_str.len()
|
||||
};
|
||||
let shape = Shape::indented(offset + used_space, context.config);
|
||||
if let Some(trait_ref_str) = trait_ref.rewrite(context, shape) {
|
||||
if !(retry && trait_ref_str.contains('\n')) {
|
||||
return Some(format!("{} {}{}", generics_str, polarity_str, &trait_ref_str));
|
||||
return Some(format!(
|
||||
"{} {}{}",
|
||||
generics_str,
|
||||
polarity_str,
|
||||
&trait_ref_str
|
||||
));
|
||||
}
|
||||
}
|
||||
// We could not make enough space for trait_ref, so put it on new line.
|
||||
@ -810,26 +845,29 @@ fn rewrite_trait_ref(context: &RewriteContext,
|
||||
let offset = offset.block_indent(context.config);
|
||||
let shape = Shape::indented(offset, context.config);
|
||||
let trait_ref_str = try_opt!(trait_ref.rewrite(context, shape));
|
||||
Some(format!("{}\n{}{}{}",
|
||||
generics_str,
|
||||
&offset.to_string(context.config),
|
||||
polarity_str,
|
||||
&trait_ref_str))
|
||||
Some(format!(
|
||||
"{}\n{}{}{}",
|
||||
generics_str,
|
||||
&offset.to_string(context.config),
|
||||
polarity_str,
|
||||
&trait_ref_str
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_struct(context: &RewriteContext,
|
||||
item_name: &str,
|
||||
ident: ast::Ident,
|
||||
vis: &ast::Visibility,
|
||||
struct_def: &ast::VariantData,
|
||||
generics: Option<&ast::Generics>,
|
||||
span: Span,
|
||||
offset: Indent,
|
||||
one_line_width: Option<usize>)
|
||||
-> Option<String> {
|
||||
pub fn format_struct(
|
||||
context: &RewriteContext,
|
||||
item_name: &str,
|
||||
ident: ast::Ident,
|
||||
vis: &ast::Visibility,
|
||||
struct_def: &ast::VariantData,
|
||||
generics: Option<&ast::Generics>,
|
||||
span: Span,
|
||||
offset: Indent,
|
||||
one_line_width: Option<usize>,
|
||||
) -> Option<String> {
|
||||
match *struct_def {
|
||||
ast::VariantData::Unit(..) => Some(format_unit_struct(item_name, ident, vis)),
|
||||
ast::VariantData::Tuple(ref fields, _) => {
|
||||
@ -877,8 +915,12 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent)
|
||||
let body_lo = context.codemap.span_after(item.span, "{");
|
||||
|
||||
let shape = Shape::indented(offset + last_line_width(&result), context.config);
|
||||
let generics_str =
|
||||
try_opt!(rewrite_generics(context, generics, shape, mk_sp(item.span.lo, body_lo)));
|
||||
let generics_str = try_opt!(rewrite_generics(
|
||||
context,
|
||||
generics,
|
||||
shape,
|
||||
mk_sp(item.span.lo, body_lo),
|
||||
));
|
||||
result.push_str(&generics_str);
|
||||
|
||||
let trait_bound_str = try_opt!(rewrite_trait_bounds(
|
||||
@ -1534,10 +1576,12 @@ pub fn rewrite_associated_type(
|
||||
let type_bounds_str = if let Some(ty_param_bounds) = ty_param_bounds_opt {
|
||||
let shape = Shape::legacy(context.config.max_width(), indent);
|
||||
let bounds: &[_] = ty_param_bounds;
|
||||
let bound_str = try_opt!(bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, shape))
|
||||
.collect::<Option<Vec<_>>>());
|
||||
let bound_str = try_opt!(
|
||||
bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, shape))
|
||||
.collect::<Option<Vec<_>>>()
|
||||
);
|
||||
if bounds.len() > 0 {
|
||||
format!(": {}", join_bounds(context, shape, &bound_str))
|
||||
} else {
|
||||
@ -2269,7 +2313,8 @@ fn compute_budgets_for_args(
|
||||
// 4 = "() {".len()
|
||||
let multi_line_overhead = indent.width() + result.len() +
|
||||
if newline_brace { 2 } else { 4 };
|
||||
let multi_line_budget = try_opt!(context.config.max_width().checked_sub(multi_line_overhead));
|
||||
let multi_line_budget =
|
||||
try_opt!(context.config.max_width().checked_sub(multi_line_overhead));
|
||||
|
||||
return Some((
|
||||
one_line_budget,
|
||||
@ -2295,22 +2340,24 @@ fn newline_for_brace(config: &Config, where_clause: &ast::WhereClause) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
fn rewrite_generics(context: &RewriteContext,
|
||||
generics: &ast::Generics,
|
||||
shape: Shape,
|
||||
span: Span)
|
||||
-> Option<String> {
|
||||
fn rewrite_generics(
|
||||
context: &RewriteContext,
|
||||
generics: &ast::Generics,
|
||||
shape: Shape,
|
||||
span: Span,
|
||||
) -> Option<String> {
|
||||
let shape = generics_shape_from_config(context.config, shape, 0);
|
||||
rewrite_generics_inner(context, generics, shape, shape.width, span)
|
||||
.or_else(|| rewrite_generics_inner(context, generics, shape, 0, span))
|
||||
}
|
||||
|
||||
fn rewrite_generics_inner(context: &RewriteContext,
|
||||
generics: &ast::Generics,
|
||||
shape: Shape,
|
||||
one_line_width: usize,
|
||||
span: Span)
|
||||
-> Option<String> {
|
||||
fn rewrite_generics_inner(
|
||||
context: &RewriteContext,
|
||||
generics: &ast::Generics,
|
||||
shape: Shape,
|
||||
one_line_width: usize,
|
||||
span: Span,
|
||||
) -> Option<String> {
|
||||
// FIXME: convert bounds to where clauses where they get too big or if
|
||||
// there is a where clause at all.
|
||||
let lifetimes: &[_] = &generics.lifetimes;
|
||||
@ -2334,15 +2381,17 @@ fn rewrite_generics_inner(context: &RewriteContext,
|
||||
});
|
||||
let ty_spans = tys.iter().map(span_for_ty_param);
|
||||
|
||||
let items = itemize_list(context.codemap,
|
||||
lt_spans.chain(ty_spans).zip(lt_strs.chain(ty_strs)),
|
||||
">",
|
||||
|&(sp, _)| sp.lo,
|
||||
|&(sp, _)| sp.hi,
|
||||
// FIXME: don't clone
|
||||
|&(_, ref str)| str.clone(),
|
||||
context.codemap.span_after(span, "<"),
|
||||
span.hi);
|
||||
let items = itemize_list(
|
||||
context.codemap,
|
||||
lt_spans.chain(ty_spans).zip(lt_strs.chain(ty_strs)),
|
||||
">",
|
||||
|&(sp, _)| sp.lo,
|
||||
|&(sp, _)| sp.hi,
|
||||
// FIXME: don't clone
|
||||
|&(_, ref str)| str.clone(),
|
||||
context.codemap.span_after(span, "<"),
|
||||
span.hi,
|
||||
);
|
||||
format_generics_item_list(context, items, shape, one_line_width)
|
||||
}
|
||||
|
||||
@ -2357,12 +2406,14 @@ pub fn generics_shape_from_config(config: &Config, shape: Shape, offset: usize)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_generics_item_list<I>(context: &RewriteContext,
|
||||
items: I,
|
||||
shape: Shape,
|
||||
one_line_budget: usize)
|
||||
-> Option<String>
|
||||
where I: Iterator<Item = ListItem>
|
||||
pub fn format_generics_item_list<I>(
|
||||
context: &RewriteContext,
|
||||
items: I,
|
||||
shape: Shape,
|
||||
one_line_budget: usize,
|
||||
) -> Option<String>
|
||||
where
|
||||
I: Iterator<Item = ListItem>,
|
||||
{
|
||||
let item_vec = items.collect::<Vec<_>>();
|
||||
|
||||
@ -2381,21 +2432,29 @@ pub fn format_generics_item_list<I>(context: &RewriteContext,
|
||||
|
||||
let list_str = try_opt!(write_list(&item_vec, &fmt));
|
||||
|
||||
Some(wrap_generics_with_angle_brackets(context, &list_str, shape.indent))
|
||||
Some(wrap_generics_with_angle_brackets(
|
||||
context,
|
||||
&list_str,
|
||||
shape.indent,
|
||||
))
|
||||
}
|
||||
|
||||
pub fn wrap_generics_with_angle_brackets(context: &RewriteContext,
|
||||
list_str: &str,
|
||||
list_offset: Indent)
|
||||
-> String {
|
||||
pub fn wrap_generics_with_angle_brackets(
|
||||
context: &RewriteContext,
|
||||
list_str: &str,
|
||||
list_offset: Indent,
|
||||
) -> String {
|
||||
if context.config.generics_indent() == IndentStyle::Block &&
|
||||
(list_str.contains('\n') || list_str.ends_with(',')) {
|
||||
format!("<\n{}{}\n{}>",
|
||||
list_offset.to_string(context.config),
|
||||
list_str,
|
||||
list_offset
|
||||
.block_unindent(context.config)
|
||||
.to_string(context.config))
|
||||
(list_str.contains('\n') || list_str.ends_with(','))
|
||||
{
|
||||
format!(
|
||||
"<\n{}{}\n{}>",
|
||||
list_offset.to_string(context.config),
|
||||
list_str,
|
||||
list_offset.block_unindent(context.config).to_string(
|
||||
context.config,
|
||||
)
|
||||
)
|
||||
} else if context.config.spaces_within_angle_brackets() {
|
||||
format!("< {} >", list_str)
|
||||
} else {
|
||||
@ -2413,10 +2472,12 @@ fn rewrite_trait_bounds(
|
||||
if bounds.is_empty() {
|
||||
return Some(String::new());
|
||||
}
|
||||
let bound_str = try_opt!(bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(&context, shape))
|
||||
.collect::<Option<Vec<_>>>());
|
||||
let bound_str = try_opt!(
|
||||
bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(&context, shape))
|
||||
.collect::<Option<Vec<_>>>()
|
||||
);
|
||||
Some(format!(": {}", join_bounds(context, shape, &bound_str)))
|
||||
}
|
||||
|
||||
@ -2446,14 +2507,16 @@ fn rewrite_where_clause_rfc_style(
|
||||
let len = where_clause.predicates.len();
|
||||
let end_of_preds = span_for_where_pred(&where_clause.predicates[len - 1]).hi;
|
||||
let span_end = span_end.unwrap_or(end_of_preds);
|
||||
let items = itemize_list(context.codemap,
|
||||
where_clause.predicates.iter(),
|
||||
terminator,
|
||||
|pred| span_for_where_pred(pred).lo,
|
||||
|pred| span_for_where_pred(pred).hi,
|
||||
|pred| pred.rewrite(context, shape),
|
||||
span_start,
|
||||
span_end);
|
||||
let items = itemize_list(
|
||||
context.codemap,
|
||||
where_clause.predicates.iter(),
|
||||
terminator,
|
||||
|pred| span_for_where_pred(pred).lo,
|
||||
|pred| span_for_where_pred(pred).hi,
|
||||
|pred| pred.rewrite(context, shape),
|
||||
span_start,
|
||||
span_end,
|
||||
);
|
||||
let comma_tactic = if suppress_comma {
|
||||
SeparatorTactic::Never
|
||||
} else {
|
||||
|
@ -468,8 +468,10 @@ where
|
||||
}
|
||||
// Reset the error count.
|
||||
if parse_session.span_diagnostic.has_errors() {
|
||||
let silent_emitter = Box::new(EmitterWriter::new(Box::new(Vec::new()),
|
||||
Some(codemap.clone())));
|
||||
let silent_emitter = Box::new(EmitterWriter::new(
|
||||
Box::new(Vec::new()),
|
||||
Some(codemap.clone()),
|
||||
));
|
||||
parse_session.span_diagnostic = Handler::with_emitter(true, false, silent_emitter);
|
||||
}
|
||||
}
|
||||
|
26
src/lists.rs
26
src/lists.rs
@ -555,20 +555,20 @@ pub fn struct_lit_shape(
|
||||
prefix_width: usize,
|
||||
suffix_width: usize,
|
||||
) -> Option<(Option<Shape>, Shape)> {
|
||||
let v_shape =
|
||||
match context.config.struct_lit_style() {
|
||||
IndentStyle::Visual => {
|
||||
try_opt!(try_opt!(shape.visual_indent(0).shrink_left(prefix_width))
|
||||
.sub_width(suffix_width))
|
||||
let v_shape = match context.config.struct_lit_style() {
|
||||
IndentStyle::Visual => {
|
||||
try_opt!(
|
||||
try_opt!(shape.visual_indent(0).shrink_left(prefix_width)).sub_width(suffix_width)
|
||||
)
|
||||
}
|
||||
IndentStyle::Block => {
|
||||
let shape = shape.block_indent(context.config.tab_spaces());
|
||||
Shape {
|
||||
width: try_opt!(context.config.max_width().checked_sub(shape.indent.width())),
|
||||
..shape
|
||||
}
|
||||
IndentStyle::Block => {
|
||||
let shape = shape.block_indent(context.config.tab_spaces());
|
||||
Shape {
|
||||
width: try_opt!(context.config.max_width().checked_sub(shape.indent.width())),
|
||||
..shape
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
let h_shape = shape.sub_width(prefix_width + suffix_width);
|
||||
Some((h_shape, v_shape))
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ impl Rewrite for Pat {
|
||||
rewrite_path(context, PathContext::Expr, q_self.as_ref(), path, shape)
|
||||
}
|
||||
PatKind::TupleStruct(ref path, ref pat_vec, dotdot_pos) => {
|
||||
let path_str = try_opt!(rewrite_path(context, PathContext::Expr, None, path, shape));
|
||||
let path_str =
|
||||
try_opt!(rewrite_path(context, PathContext::Expr, None, path, shape));
|
||||
rewrite_tuple_pat(
|
||||
pat_vec,
|
||||
dotdot_pos,
|
||||
|
@ -42,12 +42,10 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String>
|
||||
|
||||
// `cur_start` is the position in `orig` of the start of the current line.
|
||||
let mut cur_start = 0;
|
||||
let mut result = String::with_capacity(
|
||||
stripped_str
|
||||
.len()
|
||||
.checked_next_power_of_two()
|
||||
.unwrap_or(usize::max_value()),
|
||||
);
|
||||
let mut result =
|
||||
String::with_capacity(stripped_str.len().checked_next_power_of_two().unwrap_or(
|
||||
usize::max_value(),
|
||||
));
|
||||
result.push_str(fmt.opener);
|
||||
|
||||
let ender_length = fmt.line_end.len();
|
||||
|
76
src/types.rs
76
src/types.rs
@ -226,18 +226,22 @@ fn rewrite_segment(
|
||||
|
||||
let generics_shape =
|
||||
generics_shape_from_config(context.config, shape, separator.len());
|
||||
let items = itemize_list(context.codemap,
|
||||
param_list.into_iter(),
|
||||
">",
|
||||
|param| param.get_span().lo,
|
||||
|param| param.get_span().hi,
|
||||
|seg| seg.rewrite(context, generics_shape),
|
||||
list_lo,
|
||||
span_hi);
|
||||
let generics_str = try_opt!(format_generics_item_list(context,
|
||||
items,
|
||||
generics_shape,
|
||||
generics_shape.width));
|
||||
let items = itemize_list(
|
||||
context.codemap,
|
||||
param_list.into_iter(),
|
||||
">",
|
||||
|param| param.get_span().lo,
|
||||
|param| param.get_span().hi,
|
||||
|seg| seg.rewrite(context, generics_shape),
|
||||
list_lo,
|
||||
span_hi,
|
||||
);
|
||||
let generics_str = try_opt!(format_generics_item_list(
|
||||
context,
|
||||
items,
|
||||
generics_shape,
|
||||
generics_shape.width,
|
||||
));
|
||||
|
||||
// Update position of last bracket.
|
||||
*span_lo = next_span_lo;
|
||||
@ -307,9 +311,9 @@ where
|
||||
context.codemap,
|
||||
// FIXME Would be nice to avoid this allocation,
|
||||
// but I couldn't get the types to work out.
|
||||
inputs
|
||||
.map(|i| ArgumentKind::Regular(Box::new(i)))
|
||||
.chain(variadic_arg),
|
||||
inputs.map(|i| ArgumentKind::Regular(Box::new(i))).chain(
|
||||
variadic_arg,
|
||||
),
|
||||
")",
|
||||
|arg| match *arg {
|
||||
ArgumentKind::Regular(ref ty) => ty.span().lo,
|
||||
@ -387,11 +391,12 @@ impl Rewrite for ast::WherePredicate {
|
||||
// 6 = "for<> ".len()
|
||||
let used_width = lifetime_str.len() + type_str.len() + colon.len() + 6;
|
||||
let ty_shape = try_opt!(shape.block_left(used_width));
|
||||
let bounds: Vec<_> =
|
||||
try_opt!(bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
|
||||
.collect());
|
||||
let bounds: Vec<_> = try_opt!(
|
||||
bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
|
||||
.collect()
|
||||
);
|
||||
let bounds_str = join_bounds(context, ty_shape, &bounds);
|
||||
|
||||
if context.config.spaces_within_angle_brackets() && lifetime_str.len() > 0 {
|
||||
@ -411,11 +416,12 @@ impl Rewrite for ast::WherePredicate {
|
||||
Style::Legacy => try_opt!(shape.block_left(used_width)),
|
||||
Style::Rfc => shape.block_indent(context.config.tab_spaces()),
|
||||
};
|
||||
let bounds: Vec<_> =
|
||||
try_opt!(bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
|
||||
.collect());
|
||||
let bounds: Vec<_> = try_opt!(
|
||||
bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, ty_shape))
|
||||
.collect()
|
||||
);
|
||||
let bounds_str = join_bounds(context, ty_shape, &bounds);
|
||||
|
||||
format!("{}{}{}", type_str, colon, bounds_str)
|
||||
@ -482,10 +488,12 @@ where
|
||||
);
|
||||
let colon = type_bound_colon(context);
|
||||
let overhead = last_line_width(&result) + colon.len();
|
||||
let result = format!("{}{}{}",
|
||||
result,
|
||||
colon,
|
||||
join_bounds(context, try_opt!(shape.sub_width(overhead)), &appendix));
|
||||
let result = format!(
|
||||
"{}{}{}",
|
||||
result,
|
||||
colon,
|
||||
join_bounds(context, try_opt!(shape.sub_width(overhead)), &appendix)
|
||||
);
|
||||
wrap_str(result, context.config.max_width(), shape)
|
||||
}
|
||||
}
|
||||
@ -540,10 +548,12 @@ impl Rewrite for ast::TyParam {
|
||||
result.push_str(&self.ident.to_string());
|
||||
if !self.bounds.is_empty() {
|
||||
result.push_str(type_bound_colon(context));
|
||||
let strs: Vec<_> = try_opt!(self.bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, shape))
|
||||
.collect());
|
||||
let strs: Vec<_> = try_opt!(
|
||||
self.bounds
|
||||
.iter()
|
||||
.map(|ty_bound| ty_bound.rewrite(context, shape))
|
||||
.collect()
|
||||
);
|
||||
result.push_str(&join_bounds(context, shape, &strs));
|
||||
}
|
||||
if let Some(ref def) = self.default {
|
||||
|
@ -1,24 +1,27 @@
|
||||
// #1357
|
||||
impl<'a, Select, From, Distinct, Where, Order, Limit, Offset, Groupby, DB> InternalBoxedDsl<'a, DB>
|
||||
for SelectStatement<Select, From, Distinct, Where, Order, Limit, Offset, GroupBy>
|
||||
where DB: Backend,
|
||||
Select: QueryFragment<DB> + SelectableExpression<From> + 'a,
|
||||
Distinct: QueryFragment<DB> + 'a,
|
||||
Where: Into<Option<Box<QueryFragment<DB> + 'a>>>,
|
||||
Order: QueryFragment<DB> + 'a,
|
||||
Limit: QueryFragment<DB> + 'a,
|
||||
Offset: QueryFragment<DB> + 'a
|
||||
where
|
||||
DB: Backend,
|
||||
Select: QueryFragment<DB> + SelectableExpression<From> + 'a,
|
||||
Distinct: QueryFragment<DB> + 'a,
|
||||
Where: Into<Option<Box<QueryFragment<DB> + 'a>>>,
|
||||
Order: QueryFragment<DB> + 'a,
|
||||
Limit: QueryFragment<DB> + 'a,
|
||||
Offset: QueryFragment<DB> + 'a,
|
||||
{
|
||||
type Output = BoxedSelectStatement<'a, Select::SqlTypeForSelect, From, DB>;
|
||||
|
||||
fn internal_into_boxed(self) -> Self::Output {
|
||||
BoxedSelectStatement::new(Box::new(self.select),
|
||||
self.from,
|
||||
Box::new(self.distinct),
|
||||
self.where_clause.into(),
|
||||
Box::new(self.order),
|
||||
Box::new(self.limit),
|
||||
Box::new(self.offset))
|
||||
BoxedSelectStatement::new(
|
||||
Box::new(self.select),
|
||||
self.from,
|
||||
Box::new(self.distinct),
|
||||
self.where_clause.into(),
|
||||
Box::new(self.order),
|
||||
Box::new(self.limit),
|
||||
Box::new(self.offset),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,32 +34,39 @@ impl Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessiv
|
||||
for Bar {
|
||||
fn foo() {}
|
||||
}
|
||||
impl<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> Foo<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> for Bar {
|
||||
impl<
|
||||
ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName,
|
||||
> Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName>
|
||||
for Bar {
|
||||
fn foo() {}
|
||||
}
|
||||
impl<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName> Foo
|
||||
for Bar<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> {
|
||||
for Bar<
|
||||
ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName,
|
||||
> {
|
||||
fn foo() {}
|
||||
}
|
||||
impl Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName>
|
||||
for Bar<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> {
|
||||
for Bar<
|
||||
ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName,
|
||||
> {
|
||||
fn foo() {}
|
||||
}
|
||||
impl<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> Foo<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName>
|
||||
for Bar<ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName> {
|
||||
impl<
|
||||
ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName,
|
||||
> Foo<ExcessivelyLongGenericName, ExcessivelyLongGenericName, AnotherExcessivelyLongGenericName>
|
||||
for Bar<
|
||||
ExcessivelyLongGenericName,
|
||||
ExcessivelyLongGenericName,
|
||||
AnotherExcessivelyLongGenericName,
|
||||
> {
|
||||
fn foo() {}
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ fn lorem<
|
||||
Adipiscing: Eq = usize,
|
||||
Consectetur: Eq = usize,
|
||||
Elit: Eq = usize,
|
||||
>(ipsum: Ipsum,
|
||||
>(
|
||||
ipsum: Ipsum,
|
||||
dolor: Dolor,
|
||||
sit: Sit,
|
||||
amet: Amet,
|
||||
|
@ -8,8 +8,10 @@ fn simple(
|
||||
fn op(
|
||||
x: Typ,
|
||||
key: &[u8],
|
||||
upd: Box<Fn(Option<&memcache::Item>)
|
||||
-> (memcache::Status, Result<memcache::Item, Option<String>>)>,
|
||||
upd: Box<
|
||||
Fn(Option<&memcache::Item>)
|
||||
-> (memcache::Status, Result<memcache::Item, Option<String>>),
|
||||
>,
|
||||
) -> MapResult {
|
||||
}
|
||||
|
||||
@ -33,14 +35,14 @@ fn weird_comment(
|
||||
fn generic<T>(arg: T) -> &SomeType
|
||||
where
|
||||
T: Fn(// First arg
|
||||
A,
|
||||
// Second argument
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
// pre comment
|
||||
E /* last comment */)
|
||||
-> &SomeType,
|
||||
A,
|
||||
// Second argument
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
// pre comment
|
||||
E /* last comment */)
|
||||
-> &SomeType,
|
||||
{
|
||||
arg(a, b, c, d, e)
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ pub fn render<
|
||||
N: Clone + 'a,
|
||||
E: Clone + 'a,
|
||||
G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
|
||||
W: Write
|
||||
W: Write,
|
||||
>(
|
||||
g: &'a G,
|
||||
w: &mut W,
|
||||
@ -101,7 +101,10 @@ fn foo(a: i32) -> i32 {
|
||||
|
||||
fn ______________________baz(
|
||||
a: i32,
|
||||
) -> *mut ::std::option::Option<extern "C" fn(arg1: i32, _____________________a: i32, arg3: i32) -> ()> {
|
||||
) -> *mut ::std::option::Option<
|
||||
extern "C" fn(arg1: i32, _____________________a: i32, arg3: i32)
|
||||
-> (),
|
||||
> {
|
||||
}
|
||||
|
||||
pub fn check_path<'a, 'tcx>(
|
||||
|
@ -58,14 +58,14 @@ fn main() {
|
||||
fn generic<T>(arg: T) -> &SomeType
|
||||
where
|
||||
T: Fn(// First arg
|
||||
A,
|
||||
// Second argument
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
// pre comment
|
||||
E /* last comment */)
|
||||
-> &SomeType,
|
||||
A,
|
||||
// Second argument
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
// pre comment
|
||||
E /* last comment */)
|
||||
-> &SomeType,
|
||||
{
|
||||
arg(a, b, c, d, e)
|
||||
}
|
||||
|
@ -5,24 +5,23 @@ impl ISizeAndMarginsComputer for AbsoluteNonReplaced {
|
||||
input: &ISizeConstraintInput,
|
||||
) -> ISizeConstraintSolution {
|
||||
|
||||
let (inline_start, inline_size, margin_inline_start, margin_inline_end) =
|
||||
match (
|
||||
inline_startssssssxxxxxxsssssxxxxxxxxxssssssxxx,
|
||||
inline_startssssssxxxxxxsssssxxxxxxxxxssssssxxx,
|
||||
) {
|
||||
(MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Auto) => {
|
||||
let margin_start = inline_start_margin.specified_or_zero();
|
||||
let margin_end = inline_end_margin.specified_or_zero();
|
||||
// Now it is the same situation as inline-start Specified and inline-end
|
||||
// and inline-size Auto.
|
||||
//
|
||||
// Set inline-end to zero to calculate inline-size.
|
||||
let inline_size = block.get_shrink_to_fit_inline_size(
|
||||
available_inline_size - (margin_start + margin_end),
|
||||
);
|
||||
(Au(0), inline_size, margin_start, margin_end)
|
||||
}
|
||||
};
|
||||
let (inline_start, inline_size, margin_inline_start, margin_inline_end) = match (
|
||||
inline_startssssssxxxxxxsssssxxxxxxxxxssssssxxx,
|
||||
inline_startssssssxxxxxxsssssxxxxxxxxxssssssxxx,
|
||||
) {
|
||||
(MaybeAuto::Auto, MaybeAuto::Auto, MaybeAuto::Auto) => {
|
||||
let margin_start = inline_start_margin.specified_or_zero();
|
||||
let margin_end = inline_end_margin.specified_or_zero();
|
||||
// Now it is the same situation as inline-start Specified and inline-end
|
||||
// and inline-size Auto.
|
||||
//
|
||||
// Set inline-end to zero to calculate inline-size.
|
||||
let inline_size = block.get_shrink_to_fit_inline_size(
|
||||
available_inline_size - (margin_start + margin_end),
|
||||
);
|
||||
(Au(0), inline_size, margin_start, margin_end)
|
||||
}
|
||||
};
|
||||
|
||||
let (inline_start, inline_size, margin_inline_start, margin_inline_end) =
|
||||
match (inline_start, inline_end, computed_inline_size) {
|
||||
|
@ -5,12 +5,8 @@
|
||||
fn main() {
|
||||
match x
|
||||
{
|
||||
aaaaaaaa::Bbbbb::Ccccccccccccc(_, Some(ref x)) if x ==
|
||||
"aaaaaaaaaaa \
|
||||
aaaaaaa aaaaaa" =>
|
||||
{
|
||||
Ok(())
|
||||
}
|
||||
aaaaaaaa::Bbbbb::Ccccccccccccc(_, Some(ref x))
|
||||
if x == "aaaaaaaaaaa aaaaaaa aaaaaa" => Ok(()),
|
||||
_ => Err(x),
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,8 @@ fn guards() {
|
||||
barrrrrrrrrrrr => {}
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
if fooooooooooooooooooooo &&
|
||||
(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || cccccccccccccccccccccccccccccccccccccccc) => {
|
||||
(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || cccccccccccccccccccccccccccccccccccccccc) => {
|
||||
{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ where
|
||||
|
||||
fn baz<
|
||||
'a: 'b, // comment on 'a
|
||||
T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType /* comment on T */
|
||||
T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType, /* comment on T */
|
||||
>(
|
||||
a: A,
|
||||
b: B, // comment on b
|
||||
@ -164,11 +164,11 @@ fn deconstruct()
|
||||
fn deconstruct(
|
||||
foo: Bar,
|
||||
) -> (SocketAddr,
|
||||
Method,
|
||||
Headers,
|
||||
RequestUri,
|
||||
HttpVersion,
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) {
|
||||
Method,
|
||||
Headers,
|
||||
RequestUri,
|
||||
HttpVersion,
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) {
|
||||
}
|
||||
|
||||
#[rustfmt_skip]
|
||||
|
@ -1,18 +1,18 @@
|
||||
// rustfmt-normalize_comments: true
|
||||
|
||||
fn main() {
|
||||
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
||||
script::script_task::ScriptTask>::start(
|
||||
compositor_proxy,
|
||||
resource_task,
|
||||
image_cache_task,
|
||||
font_cache_task,
|
||||
time_profiler_chan,
|
||||
mem_profiler_chan,
|
||||
devtools_chan,
|
||||
storage_task,
|
||||
supports_clipboard,
|
||||
);
|
||||
let constellation_chan =
|
||||
Constellation::<layout::layout_task::LayoutTask, script::script_task::ScriptTask>::start(
|
||||
compositor_proxy,
|
||||
resource_task,
|
||||
image_cache_task,
|
||||
font_cache_task,
|
||||
time_profiler_chan,
|
||||
mem_profiler_chan,
|
||||
devtools_chan,
|
||||
storage_task,
|
||||
supports_clipboard,
|
||||
);
|
||||
|
||||
Quux::<ParamOne /* Comment 1 */, ParamTwo /* Comment 2 */>::some_func();
|
||||
|
||||
|
@ -25,10 +25,9 @@ formatting"#;
|
||||
|
||||
filename.replace(" ", "\\");
|
||||
|
||||
let xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx =
|
||||
funktion(
|
||||
"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
|
||||
);
|
||||
let xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = funktion(
|
||||
"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
|
||||
);
|
||||
|
||||
let unicode = "a̐éö̲\r\n";
|
||||
let unicode2 = "Löwe 老虎 Léopard";
|
||||
|
@ -11,7 +11,12 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn f<S, T>(x: T, y: S) -> T
|
||||
fn f<
|
||||
S, T,
|
||||
>(
|
||||
x: T,
|
||||
y: S,
|
||||
) -> T
|
||||
where
|
||||
T: P,
|
||||
S: Q,
|
||||
@ -31,8 +36,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
struct Pair<S, T>
|
||||
where
|
||||
struct Pair<
|
||||
S, T,
|
||||
> where
|
||||
T: P,
|
||||
S: P + Q,
|
||||
{
|
||||
@ -40,36 +46,56 @@ where
|
||||
b: S,
|
||||
}
|
||||
|
||||
struct TupPair<S, T>(S, T)
|
||||
struct TupPair<
|
||||
S, T,
|
||||
>(S, T)
|
||||
where
|
||||
T: P,
|
||||
S: P + Q;
|
||||
|
||||
enum E<S, T>
|
||||
where
|
||||
enum E<
|
||||
S, T,
|
||||
> where
|
||||
S: P,
|
||||
T: P,
|
||||
{
|
||||
A { a: T, },
|
||||
}
|
||||
|
||||
type Double<T> where
|
||||
type Double<
|
||||
T,
|
||||
> where
|
||||
T: P,
|
||||
T: Q = Pair<T, T>;
|
||||
T: Q = Pair<
|
||||
T, T,
|
||||
>;
|
||||
|
||||
extern "C" {
|
||||
fn f<S, T>(x: T, y: S) -> T
|
||||
fn f<
|
||||
S, T,
|
||||
>(
|
||||
x: T,
|
||||
y: S,
|
||||
) -> T
|
||||
where
|
||||
T: P,
|
||||
S: Q;
|
||||
}
|
||||
|
||||
trait Q<S, T>
|
||||
where
|
||||
trait Q<
|
||||
S, T,
|
||||
> where
|
||||
T: P,
|
||||
S: R,
|
||||
{
|
||||
fn f<U, V>(self, x: T, y: S, z: U) -> Self
|
||||
fn f<
|
||||
U, V,
|
||||
>(
|
||||
self,
|
||||
x: T,
|
||||
y: S,
|
||||
z: U,
|
||||
) -> Self
|
||||
where
|
||||
U: P,
|
||||
V: P;
|
||||
|
@ -65,7 +65,9 @@ fn issue775() {
|
||||
(
|
||||
"b".to_string(),
|
||||
Array(vec![
|
||||
mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
|
||||
mk_object(
|
||||
&[("c".to_string(), String("\x0c\r".to_string()))]
|
||||
),
|
||||
mk_object(&[("d".to_string(), String("".to_string()))]),
|
||||
]),
|
||||
),
|
||||
|
@ -3,9 +3,11 @@
|
||||
type PrivateTest<'a, I> = (Box<Parser<Input = I, Output = char> + 'a>,
|
||||
Box<Parser<Input = I, Output = char> + 'a>);
|
||||
|
||||
pub type PublicTest<'a, I, O> = Result<Vec<MyLongType>,
|
||||
Box<Parser<Input = I, Output = char> + 'a>,
|
||||
Box<Parser<Input = I, Output = char> + 'a>>;
|
||||
pub type PublicTest<'a, I, O> = Result<
|
||||
Vec<MyLongType>,
|
||||
Box<Parser<Input = I, Output = char> + 'a>,
|
||||
Box<Parser<Input = I, Output = char> + 'a>,
|
||||
>;
|
||||
|
||||
pub type LongGenericListTest<
|
||||
'a,
|
||||
@ -17,7 +19,7 @@ pub type LongGenericListTest<
|
||||
LONGPARAMETERNAME,
|
||||
A,
|
||||
B,
|
||||
C
|
||||
C,
|
||||
> = Option<Vec<MyType>>;
|
||||
|
||||
pub type Exactly100CharsTest<'a, 'b, 'c, 'd, LONGPARAMETERNAME, LONGPARAMETERNAME, A, B> = Vec<i32>;
|
||||
@ -37,13 +39,13 @@ pub type GenericsFitButNotEqualTest<
|
||||
LONGPARAMETERNAME,
|
||||
A1,
|
||||
B,
|
||||
C
|
||||
C,
|
||||
> = Vec<i32>;
|
||||
|
||||
pub type CommentTest<
|
||||
// Lifetime
|
||||
'a, // Type
|
||||
T
|
||||
T,
|
||||
> = ();
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user