Format source codes and add a test
This commit is contained in:
parent
2f17c31fa4
commit
0d5768964b
16
src/expr.rs
16
src/expr.rs
@ -750,14 +750,14 @@ fn and_one_line(x: Option<String>) -> Option<String> {
|
||||
|
||||
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)
|
||||
{
|
||||
"{}".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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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<String> {
|
||||
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)
|
||||
}
|
||||
|
19
tests/target/issue-1681.rs
Normal file
19
tests/target/issue-1681.rs
Normal file
@ -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)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user