diff --git a/src/expr.rs b/src/expr.rs index 61cd9ad0cfc..22f963e0609 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -750,14 +750,14 @@ 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) - { - "{}".to_owned() - } else { - block_str.to_owned() + 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 { + block_str.to_owned() + } }) } diff --git a/src/imports.rs b/src/imports.rs index 3b7c47f0fca..e3c06ae7956 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -159,9 +159,9 @@ impl Rewrite for ast::ViewPath { // Returns an empty string when the ViewPath is empty (like foo::bar::{}) fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option { match self.node { - ast::ViewPath_::ViewPathList(_, ref path_list) if path_list.is_empty() => { - Some(String::new()) - } + ast::ViewPath_::ViewPathList(_, ref path_list) if path_list.is_empty() => Some( + String::new(), + ), ast::ViewPath_::ViewPathList(ref path, ref path_list) => { rewrite_use_list(shape, path, path_list, self.span, context) } diff --git a/tests/target/issue-1681.rs b/tests/target/issue-1681.rs new file mode 100644 index 00000000000..a13f323e88f --- /dev/null +++ b/tests/target/issue-1681.rs @@ -0,0 +1,19 @@ +// rustfmt-max_width: 80 + +fn foo() { + // This is where it gets good + refmut_map_result(self.cache.borrow_mut(), |cache| { + match cache.entry(cache_key) { + Occupied(entry) => Ok(entry.into_mut()), + Vacant(entry) => { + let statement = { + let sql = try!(entry.key().sql(source)); + prepare_fn(&sql) + }; + + Ok(entry.insert(try!(statement))) + } + // and now, casually call a method on this + } + }).map(MaybeCached::Cached) +}