Skip to content

Commit 5e0c6f9

Browse files
committed
Avoid orphan in chain with punctuation
1 parent d85e1db commit 5e0c6f9

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

src/imports.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,12 @@ fn compare_use_items(a: &ast::Item, b: &ast::Item) -> Ordering {
127127

128128
// `extern crate foo as bar;`
129129
// ^^^ Comparing this.
130-
let result = match (a_name, b_name) {
130+
match (a_name, b_name) {
131131
(Some(..), None) => Ordering::Greater,
132132
(None, Some(..)) => Ordering::Less,
133133
(None, None) => Ordering::Equal,
134134
(Some(..), Some(..)) => a.ident.name.as_str().cmp(&b.ident.name.as_str()),
135-
};
136-
result
135+
}
137136
}
138137
_ => unreachable!(),
139138
}

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![feature(decl_macro)]
1212
#![feature(match_default_bindings)]
13-
#![feature(rustc_private)]
1413
#![feature(type_ascription)]
1514

1615
#[macro_use]

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub fn last_line_extendable(s: &str) -> bool {
178178
}
179179
for c in s.chars().rev() {
180180
match c {
181-
')' | ']' | '}' | '?' | '>' => continue,
181+
'(' | ')' | ']' | '}' | '?' | '>' => continue,
182182
'\n' => break,
183183
_ if c.is_whitespace() => continue,
184184
_ => return false,

tests/source/chains.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,18 @@ impl Foo {
214214
}).collect();
215215
}
216216
}
217+
218+
// #2415
219+
// Avoid orphan in chain
220+
fn issue2415() {
221+
let base_url = (|| {
222+
// stuff
223+
224+
Ok((|| {
225+
// stuff
226+
Some(value.to_string())
227+
})()
228+
.ok_or("")?)
229+
})()
230+
.unwrap_or_else(|_: Box<::std::error::Error>| String::from(""));
231+
}

tests/target/chains.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,16 @@ impl Foo {
246246
.collect();
247247
}
248248
}
249+
250+
// #2415
251+
// Avoid orphan in chain
252+
fn issue2415() {
253+
let base_url = (|| {
254+
// stuff
255+
256+
Ok((|| {
257+
// stuff
258+
Some(value.to_string())
259+
})().ok_or("")?)
260+
})().unwrap_or_else(|_: Box<::std::error::Error>| String::from(""));
261+
}

0 commit comments

Comments
 (0)