From 8955eb86e621c0713a9adacad79965bd6eb9af94 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 14 Jun 2017 20:33:54 +0900 Subject: [PATCH 1/5] Direct format vec! instead of using rewrite_pair --- src/macros.rs | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 562e776f8d3..cfc14b53adb 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -30,7 +30,7 @@ use Shape; use codemap::SpanUtils; use rewrite::{Rewrite, RewriteContext}; -use expr::{rewrite_call, rewrite_array, rewrite_pair}; +use expr::{rewrite_call, rewrite_array}; use comment::{FindUncommented, contains_comment}; use utils::mk_sp; @@ -192,15 +192,28 @@ pub fn rewrite_macro( } else { ("[", "]") }; - rewrite_pair( - &*expr_vec[0], - &*expr_vec[1], - lbr, - "; ", - rbr, - context, - mac_shape, - ).map(|s| format!("{}{}", macro_name, s)) + // 6 = `vec!` + `; ` + let total_overhead = lbr.len() + rbr.len() + 6; + let lhs = try_opt!(expr_vec[0].rewrite(context, mac_shape)); + let rhs = try_opt!(expr_vec[1].rewrite(context, mac_shape)); + if !lhs.contains('\n') && !rhs.contains('\n') && + lhs.len() + rhs.len() + total_overhead <= shape.width + { + Some(format!("{}{}{}; {}{}", macro_name, lbr, lhs, rhs, rbr)) + } else { + let nested_indent = shape.indent.block_indent(context.config); + Some(format!( + "{}{}\n{}{};\n{}{}\n{}{}", + macro_name, + lbr, + nested_indent.to_string(context.config), + lhs, + nested_indent.to_string(context.config), + rhs, + shape.indent.to_string(context.config), + rbr + )) + } } else { // Format macro invocation as array literal. let rewrite = try_opt!(rewrite_array( From 496e95846745aaa3f90c07cfd24bea1b6b24a0fa Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 14 Jun 2017 20:36:28 +0900 Subject: [PATCH 2/5] Put match arm guard on the next line if it contains new line --- src/expr.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/expr.rs b/src/expr.rs index 1e92b5b9368..e45aa20a68a 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1650,7 +1650,9 @@ fn rewrite_guard( s.rewrite(context, cond_shape) }) { - return Some(format!(" if {}", cond_str)); + if !cond_str.contains('\n') { + return Some(format!(" if {}", cond_str)); + } } } From c06d487712c309b1ff0197916e8148cad23cb0bd Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 14 Jun 2017 20:37:54 +0900 Subject: [PATCH 3/5] Add offset wherever necessary --- src/expr.rs | 83 +++++++++++++++++++++++++++++----------------------- src/items.rs | 12 +++++++- 2 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index e45aa20a68a..7729ef5f10b 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -371,7 +371,9 @@ pub fn rewrite_pair( // This is needed in case of line break not caused by a // shortage of space, but by end-of-line comments, for example. if !rhs_result.contains('\n') { - let lhs_shape = try_opt!(shape.sub_width(prefix.len() + infix.len())); + let lhs_shape = try_opt!(try_opt!(shape.offset_left(prefix.len())).sub_width( + infix.len(), + )); let lhs_result = lhs.rewrite(context, lhs_shape); if let Some(lhs_result) = lhs_result { let mut result = format!("{}{}{}", prefix, lhs_result, infix); @@ -412,22 +414,23 @@ pub fn rewrite_pair( try_opt!(shape.sub_width(suffix.len() + prefix.len())).visual_indent(prefix.len()) } Style::Rfc => { - shape - .block_indent(context.config.tab_spaces()) - .with_max_width(context.config) + // Try to calculate the initial constraint on the right hand side. + let rhs_overhead = context + .config + .max_width() + .checked_sub(shape.used_width() + shape.width) + .unwrap_or(0); + try_opt!( + Shape::indented(shape.indent.block_indent(context.config), context.config) + .sub_width(rhs_overhead) + ) } }; - let rhs_result = try_opt!(rhs.rewrite(context, rhs_shape)); - let lhs_shape = match context.config.control_style() { - Style::Legacy => { - let lhs_overhead = shape.used_width() + prefix.len() + infix.len(); - Shape { - width: try_opt!(context.config.max_width().checked_sub(lhs_overhead)), - ..shape - } - } - Style::Rfc => try_opt!(shape.sub_width(prefix.len() + infix.len())), + let lhs_overhead = shape.used_width() + prefix.len() + infix.len(); + let lhs_shape = Shape { + width: try_opt!(context.config.max_width().checked_sub(lhs_overhead)), + ..shape }; let lhs_result = try_opt!(lhs.rewrite(context, lhs_shape)); Some(format!( @@ -484,12 +487,9 @@ pub fn rewrite_array<'a, I>( } } - let has_long_item = try_opt!( - items - .iter() - .map(|li| li.item.as_ref().map(|s| s.len() > 10)) - .fold(Some(false), |acc, x| acc.and_then(|y| x.map(|x| x || y))) - ); + let has_long_item = items.iter().any(|li| { + li.item.as_ref().map(|s| s.len() > 10).unwrap_or(false) + }); let tactic = match context.config.array_layout() { IndentStyle::Block => { @@ -622,7 +622,7 @@ fn rewrite_closure( // 1 = space between `|...|` and body. let extra_offset = extra_offset(&prefix, shape) + 1; - let body_shape = try_opt!(shape.sub_width(extra_offset)).add_offset(extra_offset); + let body_shape = try_opt!(shape.offset_left(extra_offset)); if let ast::ExprKind::Block(ref block) = body.node { // The body of the closure is an empty block. @@ -1020,13 +1020,13 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { let label_string = rewrite_label(self.label); // 1 = space after keyword. - let add_offset = self.keyword.len() + label_string.len() + 1; + let offset = self.keyword.len() + label_string.len() + 1; let pat_expr_string = match self.cond { Some(cond) => { let mut cond_shape = match context.config.control_style() { - Style::Legacy => try_opt!(constr_shape.shrink_left(add_offset)), - Style::Rfc => try_opt!(constr_shape.sub_width(add_offset)), + Style::Legacy => try_opt!(constr_shape.shrink_left(offset)), + Style::Rfc => try_opt!(constr_shape.offset_left(offset)), }; if context.config.control_brace_style() != ControlBraceStyle::AlwaysNextLine { // 2 = " {".len() @@ -1346,7 +1346,7 @@ fn rewrite_match( // `match `cond` {` let cond_shape = match context.config.control_style() { Style::Legacy => try_opt!(shape.shrink_left(6).and_then(|s| s.sub_width(2))), - Style::Rfc => try_opt!(shape.sub_width(8)), + Style::Rfc => try_opt!(shape.offset_left(8)), }; let cond_str = try_opt!(cond.rewrite(context, cond_shape)); let alt_block_sep = String::from("\n") + &shape.indent.block_only().to_string(context.config); @@ -1572,8 +1572,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { // FIXME: we're doing a second rewrite of the expr; This may not be // necessary. - let body_shape = try_opt!(shape.sub_width(context.config.tab_spaces())) - .block_indent(context.config.tab_spaces()); + let body_shape = try_opt!(shape.block_left(context.config.tab_spaces())); let next_line_body = try_opt!(nop_block_collapse( body.rewrite(context, body_shape), body_shape.width, @@ -1700,7 +1699,7 @@ fn rewrite_pat_expr( } else { format!("{} ", matcher) }; - let pat_shape = try_opt!(try_opt!(shape.shrink_left(matcher.len())).sub_width( + let pat_shape = try_opt!(try_opt!(shape.offset_left(matcher.len())).sub_width( connector.len(), )); pat_string = try_opt!(pat.rewrite(context, pat_shape)); @@ -2133,19 +2132,29 @@ fn wrap_args_with_parens( fn rewrite_paren(context: &RewriteContext, subexpr: &ast::Expr, shape: Shape) -> Option { debug!("rewrite_paren, shape: {:?}", shape); - // 1 is for opening paren, 2 is for opening+closing, we want to keep the closing - // paren on the same line as the subexpr. - let sub_shape = try_opt!(shape.sub_width(2)).visual_indent(1); - let subexpr_str = subexpr.rewrite(context, sub_shape); - debug!("rewrite_paren, subexpr_str: `{:?}`", subexpr_str); + let paren_overhead = paren_overhead(context); + let sub_shape = try_opt!(shape.sub_width(paren_overhead / 2)).visual_indent(paren_overhead / 2); - subexpr_str.map(|s| if context.config.spaces_within_parens() && - s.len() > 0 - { + let paren_wrapper = |s: &str| if context.config.spaces_within_parens() && s.len() > 0 { format!("( {} )", s) } else { format!("({})", s) - }) + }; + + let subexpr_str = try_opt!(subexpr.rewrite(context, sub_shape)); + debug!("rewrite_paren, subexpr_str: `{:?}`", subexpr_str); + + if subexpr_str.contains('\n') { + Some(paren_wrapper(&subexpr_str)) + } else { + if subexpr_str.len() + paren_overhead <= shape.width { + Some(paren_wrapper(&subexpr_str)) + } else { + let sub_shape = try_opt!(shape.offset_left(2)); + let subexpr_str = try_opt!(subexpr.rewrite(context, sub_shape)); + Some(paren_wrapper(&subexpr_str)) + } + } } fn rewrite_index( diff --git a/src/items.rs b/src/items.rs index 5144feed474..2e00bcbd10d 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1831,7 +1831,17 @@ fn rewrite_fn_base( result.push_str(&ident.to_string()); // Generics. - let shape = Shape::indented(indent + last_line_width(&result), context.config); + let overhead = if has_braces && !newline_brace { + // 4 = `() {` + 4 + } else { + // 2 = `()` + 2 + }; + let shape = try_opt!( + Shape::indented(indent + last_line_width(&result), context.config) + .sub_width(overhead) + ); let g_span = mk_sp(span.lo, span_for_return(&fd.output).lo); let generics_str = try_opt!(rewrite_generics(context, generics, shape, g_span)); result.push_str(&generics_str); From b8f11a4e3c1c3a381daa19da28e3e9d686c25aa0 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 14 Jun 2017 20:39:07 +0900 Subject: [PATCH 4/5] Format source codes --- src/comment.rs | 4 +-- src/expr.rs | 32 +++++++------------- src/items.rs | 25 +++++++-------- src/string.rs | 2 +- src/types.rs | 6 ++-- src/visitor.rs | 9 +++--- tests/target/configs-control_style-rfc.rs | 2 +- tests/target/configs-trailing_comma-never.rs | 8 ++--- tests/target/expr.rs | 18 ++++++----- tests/target/fn_args_layout-block.rs | 7 ++++- tests/target/hard-tabs.rs | 2 +- tests/target/issue-1397.rs | 4 +-- tests/target/macros.rs | 19 +++++++----- tests/target/match.rs | 19 +++++------- 14 files changed, 79 insertions(+), 78 deletions(-) diff --git a/src/comment.rs b/src/comment.rs index d31ba5f9f2d..e9f84b71e48 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -319,8 +319,8 @@ fn left_trim_comment_line<'a>(line: &'a str, style: &CommentStyle) -> &'a str { } else { &line[opener.trim_right().len()..] } - } else if line.starts_with("/* ") || line.starts_with("// ") || - line.starts_with("//!") || line.starts_with("///") || + } else if line.starts_with("/* ") || line.starts_with("// ") || line.starts_with("//!") || + line.starts_with("///") || line.starts_with("** ") || line.starts_with("/*!") || (line.starts_with("/**") && !line.starts_with("/**/")) { diff --git a/src/expr.rs b/src/expr.rs index 7729ef5f10b..d236448caf5 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -729,9 +729,10 @@ fn and_one_line(x: Option) -> Option { fn nop_block_collapse(block_str: Option, budget: usize) -> Option { debug!("nop_block_collapse {:?} {}", block_str, budget); - block_str.map(|block_str| if block_str.starts_with('{') && - budget >= 2 && - (block_str[1..].find(|c: char| !c.is_whitespace()).unwrap() == block_str.len() - 2) + block_str.map(|block_str| if block_str.starts_with('{') && budget >= 2 && + (block_str[1..] + .find(|c: char| !c.is_whitespace()) + .unwrap() == block_str.len() - 2) { "{}".to_owned() } else { @@ -1509,9 +1510,9 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { let pats_str = format!("{}{}", pats_str, guard_str); let (mut extend, body) = match body.node { - ast::ExprKind::Block(ref block) if !is_unsafe_block(block) && - is_simple_block(block, context.codemap) && - context.config.wrap_match_arms() => { + ast::ExprKind::Block(ref block) + if !is_unsafe_block(block) && is_simple_block(block, context.codemap) && + context.config.wrap_match_arms() => { if let ast::StmtKind::Expr(ref expr) = block.stmts[0].node { (false, &**expr) } else { @@ -2539,21 +2540,10 @@ fn count_line_breaks(src: &str) -> usize { // FIXME: DRY! match (rhs, new_rhs) { - (Some(ref orig_rhs), Some(ref replacement_rhs)) if count_line_breaks( - orig_rhs, - ) > - count_line_breaks( - replacement_rhs, - ) + 1 || - (orig_rhs - .rewrite(context, shape) - .is_none() && - replacement_rhs - .rewrite( - context, - new_shape, - ) - .is_some()) => { + (Some(ref orig_rhs), Some(ref replacement_rhs)) + if count_line_breaks(orig_rhs) > count_line_breaks(replacement_rhs) + 1 || + (orig_rhs.rewrite(context, shape).is_none() && + replacement_rhs.rewrite(context, new_shape).is_some()) => { result.push_str(&format!("\n{}", new_shape.indent.to_string(context.config))); result.push_str(replacement_rhs); } diff --git a/src/items.rs b/src/items.rs index 2e00bcbd10d..a660f287a5b 100644 --- a/src/items.rs +++ b/src/items.rs @@ -685,12 +685,12 @@ fn format_impl_ref_and_type( offset: Indent, ) -> Option { if let ast::ItemKind::Impl(unsafety, - polarity, - _, - ref generics, - ref trait_ref, - ref self_ty, - _) = item.node + polarity, + _, + ref generics, + ref trait_ref, + ref self_ty, + _) = item.node { let mut result = String::new(); @@ -942,8 +942,8 @@ pub fn format_trait(context: &RewriteContext, item: &ast::Item, offset: Indent) let has_body = !trait_items.is_empty(); let where_density = if (context.config.where_density() == Density::Compressed && - (!result.contains('\n') || - context.config.fn_args_layout() == IndentStyle::Block)) || + (!result.contains('\n') || + context.config.fn_args_layout() == IndentStyle::Block)) || (context.config.fn_args_layout() == IndentStyle::Block && result.is_empty()) || (context.config.where_density() == Density::CompressedIfEmpty && !has_body && !result.contains('\n')) @@ -1468,9 +1468,9 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { Some(ref ty) if ty.contains('\n') => { let new_ty = rewrite_type_in_next_line(); match new_ty { - Some(ref new_ty) if !new_ty.contains('\n') && - new_ty.len() + type_offset.width() <= - context.config.max_width() => { + Some(ref new_ty) + if !new_ty.contains('\n') && + new_ty.len() + type_offset.width() <= context.config.max_width() => { Some(format!( "{}\n{}{}", result, @@ -2688,7 +2688,8 @@ fn format_generics( let same_line_brace = force_same_line_brace || (generics.where_clause.predicates.is_empty() && trimmed_last_line_width(&result) == 1); if !same_line_brace && - (brace_style == BraceStyle::SameLineWhere || brace_style == BraceStyle::AlwaysNextLine) + (brace_style == BraceStyle::SameLineWhere || + brace_style == BraceStyle::AlwaysNextLine) { result.push('\n'); result.push_str(&offset.block_only().to_string(context.config)); diff --git a/src/string.rs b/src/string.rs index 6c20c18ca47..5ba273ad272 100644 --- a/src/string.rs +++ b/src/string.rs @@ -81,7 +81,7 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option if cur_end < cur_start + MIN_STRING { cur_end = cur_start + max_chars; while !(punctuation.contains(graphemes[cur_end - 1]) || - graphemes[cur_end - 1].trim().is_empty()) + graphemes[cur_end - 1].trim().is_empty()) { if cur_end >= graphemes.len() { let line = &graphemes[cur_start..].join(""); diff --git a/src/types.rs b/src/types.rs index 5e57ce790a7..3774df70146 100644 --- a/src/types.rs +++ b/src/types.rs @@ -206,9 +206,9 @@ fn rewrite_segment( let params = if let Some(ref params) = segment.parameters { match **params { - ast::PathParameters::AngleBracketed(ref data) if !data.lifetimes.is_empty() || - !data.types.is_empty() || - !data.bindings.is_empty() => { + ast::PathParameters::AngleBracketed(ref data) + if !data.lifetimes.is_empty() || !data.types.is_empty() || + !data.bindings.is_empty() => { let param_list = data.lifetimes .iter() .map(SegmentParam::LifeTime) diff --git a/src/visitor.rs b/src/visitor.rs index 7e3fed3faff..9ed40cc29ee 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -546,10 +546,11 @@ fn visit_mac(&mut self, mac: &ast::Mac, ident: Option, pos: MacroPos fn push_rewrite(&mut self, span: Span, rewrite: Option) { self.format_missing_with_indent(source!(self, span).lo); self.failed = match rewrite { - Some(ref s) if s.rewrite( - &self.get_context(), - Shape::indented(self.block_indent, self.config), - ).is_none() => true, + Some(ref s) + if s.rewrite( + &self.get_context(), + Shape::indented(self.block_indent, self.config), + ).is_none() => true, None => true, _ => self.failed, }; diff --git a/tests/target/configs-control_style-rfc.rs b/tests/target/configs-control_style-rfc.rs index 43a10e92339..20742da2195 100644 --- a/tests/target/configs-control_style-rfc.rs +++ b/tests/target/configs-control_style-rfc.rs @@ -5,7 +5,7 @@ fn main() { loop { if foo { if ((right_paddle_speed < 0.) && - (right_paddle.position().y - paddle_size.y / 2. > 5.)) || + (right_paddle.position().y - paddle_size.y / 2. > 5.)) || ((right_paddle_speed > 0.) && (right_paddle.position().y + paddle_size.y / 2. < game_height as f32 - 5.)) { diff --git a/tests/target/configs-trailing_comma-never.rs b/tests/target/configs-trailing_comma-never.rs index f38d26d64db..8f351e8dfc2 100644 --- a/tests/target/configs-trailing_comma-never.rs +++ b/tests/target/configs-trailing_comma-never.rs @@ -14,10 +14,10 @@ fn main() { // #1544 if let VrMsg::ClientReply { - request_num: reply_req_num, - value, - .. - } = msg + request_num: reply_req_num, + value, + .. + } = msg { let _ = safe_assert_eq!(reply_req_num, request_num, op); return Ok((request_num, op, value)); diff --git a/tests/target/expr.rs b/tests/target/expr.rs index 3932992af62..3b17aee5a78 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -7,8 +7,8 @@ fn foo() -> bool { let referenced = &5; let very_long_variable_name = (a + first + simple + test); - let very_long_variable_name = - (a + first + simple + test + AAAAAAAAAAAAA + BBBBBBBBBBBBBBBBB + b + c); + let very_long_variable_name = (a + first + simple + test + AAAAAAAAAAAAA + + BBBBBBBBBBBBBBBBB + b + c); let is_internalxxxx = self.codemap.span_to_filename(s) == self.codemap.span_to_filename(m.inner); @@ -20,8 +20,10 @@ fn foo() -> bool { 10000 * 30000000000 + 40000 / 1002200000000 - 50000 * sqrt(-1), trivial_value, ); - (((((((((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + a + - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaa))))))))) ; + (((((((((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + a + + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + + aaaaa))))))))); { for _ in 0..10 {} @@ -47,21 +49,21 @@ fn foo() -> bool { } if let Some(x) = (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {} if let (some_very_large, - tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 + tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 { } if let (some_very_large, - tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = + tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1111 + 2222 {} if let (some_very_large, - tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 + tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {} let test = if true { 5 } else { 3 }; diff --git a/tests/target/fn_args_layout-block.rs b/tests/target/fn_args_layout-block.rs index 93f14c526bd..1d4a1fb6792 100644 --- a/tests/target/fn_args_layout-block.rs +++ b/tests/target/fn_args_layout-block.rs @@ -96,7 +96,12 @@ fn foo() { foo(); } -fn foo() { +fn foo< + L: Loooooooooooooooooooooong, + G: Geeeeeeeeeeeneric, + I: iiiiiiiiis, + L: Looooooooooooooooong, +>() { foo(); } diff --git a/tests/target/hard-tabs.rs b/tests/target/hard-tabs.rs index 42d3875ad19..48c72afd055 100644 --- a/tests/target/hard-tabs.rs +++ b/tests/target/hard-tabs.rs @@ -22,7 +22,7 @@ fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa"; if let (some_very_large, - tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 + tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1 + 2 + 3 {} if cond() { diff --git a/tests/target/issue-1397.rs b/tests/target/issue-1397.rs index f267a91d3e1..21c3c9e38de 100644 --- a/tests/target/issue-1397.rs +++ b/tests/target/issue-1397.rs @@ -12,8 +12,8 @@ fn baz(p: Packet) { loop { loop { if let Packet::Transaction { - state: TransactionState::Committed(ts, ..), .. - } = p + state: TransactionState::Committed(ts, ..), .. + } = p { unreachable!() } diff --git a/tests/target/macros.rs b/tests/target/macros.rs index 6185e21a835..9cc3305ea39 100644 --- a/tests/target/macros.rs +++ b/tests/target/macros.rs @@ -67,13 +67,18 @@ fn main() { vec![a, b; c]; vec![a; b, c]; - vec![a; - (|x| { - let y = x + 1; - let z = y + 1; - z - })(2)]; - vec![a; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]; + vec![ + a; + (|x| { + let y = x + 1; + let z = y + 1; + z + })(2) + ]; + vec![ + a; + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + ]; vec![a; unsafe { x + 1 }]; unknown_bracket_macro__comma_should_not_be_stripped![ diff --git a/tests/target/match.rs b/tests/target/match.rs index 35b97094535..040fbf155a4 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -37,10 +37,8 @@ fn foo() { Patternnnnnnnnnnnnnnnnnnnnnnnnn if loooooooooooooooooooooooooooooooooooooooooong_guard => {} _ => {} - ast::PathParameters::AngleBracketedParameters(ref data) if data.lifetimes.len() > - 0 || - data.types.len() > 0 || - data.bindings.len() > 0 => {} + ast::PathParameters::AngleBracketedParameters(ref data) + if data.lifetimes.len() > 0 || data.types.len() > 0 || data.bindings.len() > 0 => {} } let whatever = match something { @@ -316,16 +314,15 @@ fn issue386() { fn guards() { match foo { - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if foooooooooooooo && - barrrrrrrrrrrr => {} + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + if foooooooooooooo && barrrrrrrrrrrr => {} aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if foooooooooooooo && - barrrrrrrrrrrr => {} + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + if foooooooooooooo && barrrrrrrrrrrr => {} aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa if fooooooooooooooooooooo && - (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || cccccccccccccccccccccccccccccccccccccccc) => { - {} - } + (bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb || + cccccccccccccccccccccccccccccccccccccccc) => {} } } From 866c2885f7eed4cee1b6831011ad66fcf3b468f0 Mon Sep 17 00:00:00 2001 From: topecongiro Date: Wed, 14 Jun 2017 21:07:49 +0900 Subject: [PATCH 5/5] Run travis and appveyor only against nightly --- .travis.yml | 4 ++-- appveyor.yml | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4522344e1ca..d6bf62e34d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ sudo: false language: rust rust: - - stable - - beta +# - stable +# - beta - nightly os: - linux diff --git a/appveyor.yml b/appveyor.yml index e2950ff950b..71704c494e7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,23 +6,23 @@ environment: PROJECT_NAME: rustfmt matrix: # Stable channel - - TARGET: i686-pc-windows-gnu - CHANNEL: stable - - TARGET: i686-pc-windows-msvc - CHANNEL: stable - - TARGET: x86_64-pc-windows-gnu - CHANNEL: stable - - TARGET: x86_64-pc-windows-msvc - CHANNEL: stable + # - TARGET: i686-pc-windows-gnu + # CHANNEL: stable + # - TARGET: i686-pc-windows-msvc + # CHANNEL: stable + # - TARGET: x86_64-pc-windows-gnu + # CHANNEL: stable + # - TARGET: x86_64-pc-windows-msvc + # CHANNEL: stable # Beta channel - - TARGET: i686-pc-windows-gnu - CHANNEL: beta - - TARGET: i686-pc-windows-msvc - CHANNEL: beta - - TARGET: x86_64-pc-windows-gnu - CHANNEL: beta - - TARGET: x86_64-pc-windows-msvc - CHANNEL: beta + # - TARGET: i686-pc-windows-gnu + # CHANNEL: beta + # - TARGET: i686-pc-windows-msvc + # CHANNEL: beta + # - TARGET: x86_64-pc-windows-gnu + # CHANNEL: beta + # - TARGET: x86_64-pc-windows-msvc + # CHANNEL: beta # Nightly channel - TARGET: i686-pc-windows-gnu CHANNEL: nightly