Avoid orphan in chain with punctuation
This commit is contained in:
parent
d85e1db178
commit
5e0c6f9716
@ -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!(),
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#![feature(decl_macro)]
|
||||
#![feature(match_default_bindings)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(type_ascription)]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -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,
|
||||
|
@ -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(""));
|
||||
}
|
||||
|
@ -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(""));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user