Avoid orphan in chain with punctuation

This commit is contained in:
topecongiro 2018-02-06 09:36:29 +09:00
parent d85e1db178
commit 5e0c6f9716
5 changed files with 31 additions and 5 deletions

View File

@ -127,13 +127,12 @@ fn compare_use_items(a: &ast::Item, b: &ast::Item) -> Ordering {
// `extern crate foo as bar;`
// ^^^ Comparing this.
let result = match (a_name, b_name) {
match (a_name, b_name) {
(Some(..), None) => Ordering::Greater,
(None, Some(..)) => Ordering::Less,
(None, None) => Ordering::Equal,
(Some(..), Some(..)) => a.ident.name.as_str().cmp(&b.ident.name.as_str()),
};
result
}
}
_ => unreachable!(),
}

View File

@ -10,7 +10,6 @@
#![feature(decl_macro)]
#![feature(match_default_bindings)]
#![feature(rustc_private)]
#![feature(type_ascription)]
#[macro_use]

View File

@ -178,7 +178,7 @@ pub fn last_line_extendable(s: &str) -> bool {
}
for c in s.chars().rev() {
match c {
')' | ']' | '}' | '?' | '>' => continue,
'(' | ')' | ']' | '}' | '?' | '>' => continue,
'\n' => break,
_ if c.is_whitespace() => continue,
_ => return false,

View File

@ -214,3 +214,18 @@ impl Foo {
}).collect();
}
}
// #2415
// Avoid orphan in chain
fn issue2415() {
let base_url = (|| {
// stuff
Ok((|| {
// stuff
Some(value.to_string())
})()
.ok_or("")?)
})()
.unwrap_or_else(|_: Box<::std::error::Error>| String::from(""));
}

View File

@ -246,3 +246,16 @@ impl Foo {
.collect();
}
}
// #2415
// Avoid orphan in chain
fn issue2415() {
let base_url = (|| {
// stuff
Ok((|| {
// stuff
Some(value.to_string())
})().ok_or("")?)
})().unwrap_or_else(|_: Box<::std::error::Error>| String::from(""));
}