ast::ExprKind::Lit(ref l) => {
match l.node {
ast::LitKind::Str(_, ast::StrStyle::Cooked) => {
- Some(rewrite_string_lit(context, l.span, width, offset))
+ rewrite_string_lit(context, l.span, width, offset)
}
_ => {
wrap_str(context.snippet(expr.span),
}
fn nop_block_collapse(block_str: Option<String>, budget: usize) -> Option<String> {
+ 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) {
// Match arms.
impl Rewrite for ast::Arm {
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
+ debug!("Arm::rewrite {:?} {} {:?}", self, width, offset);
let &ast::Arm { ref attrs, ref pats, ref guard, ref body } = self;
// FIXME this is all a bit grotty, would be nice to abstract out the
false
};
- let block_sep = match context.config.control_brace_style {
- ControlBraceStyle::AlwaysNextLine if is_block => alt_block_sep.as_str(),
- _ => " ",
- };
match rewrite {
Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms ||
is_block => {
+ let block_sep = match context.config.control_brace_style {
+ ControlBraceStyle::AlwaysNextLine if is_block => alt_block_sep.as_str(),
+ _ => " ",
+ };
+
return Some(format!("{}{} =>{}{}{}",
attr_str.trim_left(),
pats_str,
span: Span,
width: usize,
offset: Indent)
- -> String {
+ -> Option<String> {
let string_lit = context.snippet(span);
if !context.config.format_strings && !context.config.force_format_strings {
- return string_lit;
+ return Some(string_lit);
}
if !context.config.force_format_strings &&
!string_requires_rewrite(context, span, &string_lit, width, offset) {
- return string_lit;
+ return Some(string_lit);
}
let fmt = StringFormat {
// Remove the quote characters.
let str_lit = &string_lit[1..string_lit.len() - 1];
- rewrite_string(str_lit, &fmt).unwrap_or_else(|| string_lit.to_owned())
+ rewrite_string(str_lit, &fmt)
}
fn string_requires_rewrite(context: &RewriteContext,
let too_many_lines = "Hello";
// Make sure we don't break after an escape character.
- let odd_length_name = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
- let even_length_name = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
+ let odd_length_name =
+ "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
+ let even_length_name =
+ "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
let really_long_variable_name = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
filename.replace(" ", "\\");
- let xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = funktion("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
+ let xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx =
+ funktion("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
let unicode = "a̐éö̲\r\n";
let unicode2 = "Löwe 老虎 Léopard";
println!("forall x. mult(e(), x) = x /\\
forall x. mult(x, x) = e()");
}
+
+fn issue_1282() {
+ {
+ match foo {
+ Permission::AndroidPermissionAccessLocationExtraCommands => {
+ "android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"
+ }
+ }
+ }
+}
fn main() {
println!("ThisIsAReallyLongStringWithNoSpaces.It_should_prefer_to_break_onpunctuation:\
Likethisssssssssssss");
- format!("{}__{}__{}ItShouldOnlyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyNoticeSemicolonsPeriodsColonsAndCommasAndResortToMid-CharBreaksAfterPunctuation{}{}",
- x,
- y,
- z,
- a,
- b);
+ format!("{}__{}__{}ItShouldOnlyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyNoticeSemicolonsPeriodsColonsAndCommasAndResortToMid-CharBreaksAfterPunctuation{}{}",x,y,z,a,b);
println!("aaaaaaaaaaaaaaaaaaaaaaaaaaaaalhijalfhiigjapdighjapdigjapdighdapighapdighpaidhg;\
adopgihadoguaadbadgad,qeoihapethae8t0aet8haetadbjtaeg;\
ooeouthaoeutgadlgajduabgoiuadogabudogubaodugbadgadgadga;adoughaoeugbaouea");