]> git.lizzy.rs Git - rust.git/commitdiff
Avoid orphan in chain with punctuation
authortopecongiro <seuchida@gmail.com>
Tue, 6 Feb 2018 00:36:29 +0000 (09:36 +0900)
committertopecongiro <seuchida@gmail.com>
Tue, 6 Feb 2018 00:36:29 +0000 (09:36 +0900)
src/imports.rs
src/lib.rs
src/utils.rs
tests/source/chains.rs
tests/target/chains.rs

index 3818fd21950e126f959ad947d635dd06d67b35bd..0b65cafe730e6bdfdd70197eb10f13c413822d6b 100644 (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!(),
     }
index 2b89bde72c1672c43a1384ff4cc24744a94357c4..fc9fb2a9ce062238fc9d6706860600a18f66f0ff 100644 (file)
@@ -10,7 +10,6 @@
 
 #![feature(decl_macro)]
 #![feature(match_default_bindings)]
-#![feature(rustc_private)]
 #![feature(type_ascription)]
 
 #[macro_use]
index 443dc6c7a05edc558131a1e2842b86a372babfce..20f4fdfe6d0b86a0887783bfd750117273492f33 100644 (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,
index 0977212ef218df1e150cf1b158667144aa50a624..0ed52ae61becee572b995f974cb3ea880f648491 100644 (file)
@@ -214,3 +214,18 @@ pub fn from_ast(diagnostic: &::errors::Handler,
         }).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(""));
+}
index 6e1fc809764a5414dfd4df6321011a8ec6e4089a..8a41eec2bde313c8e528880be1d83b4d1c7fec56 100644 (file)
@@ -246,3 +246,16 @@ pub fn from_ast(diagnostic: &::errors::Handler, attrs: &[ast::Attribute]) -> Att
             .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(""));
+}