Skip to content

Avoid orphan in chain with punctuation #2417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
}
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#![feature(decl_macro)]
#![feature(match_default_bindings)]
#![feature(rustc_private)]
#![feature(type_ascription)]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions tests/source/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
}
13 changes: 13 additions & 0 deletions tests/target/chains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(""));
}