]> git.lizzy.rs Git - rust.git/commitdiff
Add a test for #2510
authorSeiichi Uchida <seuchida@gmail.com>
Wed, 7 Mar 2018 06:53:17 +0000 (15:53 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Fri, 9 Mar 2018 05:07:43 +0000 (14:07 +0900)
Closes #2510.

tests/lib.rs
tests/source/type.rs
tests/target/type.rs

index 9abe08ba9e0a292650ba34c1ec0160b7e9e2067a..4ec2c33a31a595b74f80140167d0e18eede122a2 100644 (file)
@@ -330,26 +330,28 @@ fn check_files(files: Vec<PathBuf>) -> (Vec<FormatReport>, u32, u32) {
 }
 
 fn print_mismatches_default_message(result: HashMap<PathBuf, Vec<Mismatch>>) {
-    let mut t = term::stdout().unwrap();
     for (file_name, diff) in result {
         let mismatch_msg_formatter =
             |line_num| format!("\nMismatch at {}:{}:", file_name.display(), line_num);
         print_diff(diff, &mismatch_msg_formatter, Color::Auto);
     }
 
-    t.reset().unwrap();
+    if let Some(mut t) = term::stdout() {
+        t.reset().unwrap_or(());
+    }
 }
 
 fn print_mismatches<T: Fn(u32) -> String>(
     result: HashMap<PathBuf, Vec<Mismatch>>,
     mismatch_msg_formatter: T,
 ) {
-    let mut t = term::stdout().unwrap();
     for (_file_name, diff) in result {
         print_diff(diff, &mismatch_msg_formatter, Color::Auto);
     }
 
-    t.reset().unwrap();
+    if let Some(mut t) = term::stdout() {
+        t.reset().unwrap_or(());
+    }
 }
 
 fn read_config(filename: &Path) -> Config {
index 0a46ffb2ee4a1f3da8b56dfde1626f905d8250cd..9477af52443c26b2d4717559db8bfb6f3a926296 100644 (file)
@@ -23,3 +23,18 @@ fn impl_trait_fn_2<E>() -> impl Future<Item=&'a i64,Error=E> {}
 fn issue_1234() {
     do_parse!(name: take_while1!(is_token) >> (Header))
 }
+
+// #2510
+impl CombineTypes {
+    pub fn pop_callback(
+        &self,
+        query_id: Uuid,
+    ) -> Option<
+        (
+            ProjectId,
+            Box<FnMut(&ProjectState, serde_json::Value, bool) -> () + Sync + Send>,
+        ),
+    > {
+        self.query_callbacks()(&query_id)
+    }
+}
index 2f35e79651211bd2cc5b1a1c7eb4924eb55379fc..95f7ff3d5d216d22d5810946baf8a83b0e2e44b8 100644 (file)
@@ -29,3 +29,16 @@ fn impl_trait_fn_2<E>() -> impl Future<Item = &'a i64, Error = E> {}
 fn issue_1234() {
     do_parse!(name: take_while1!(is_token) >> (Header))
 }
+
+// #2510
+impl CombineTypes {
+    pub fn pop_callback(
+        &self,
+        query_id: Uuid,
+    ) -> Option<(
+        ProjectId,
+        Box<FnMut(&ProjectState, serde_json::Value, bool) -> () + Sync + Send>,
+    )> {
+        self.query_callbacks()(&query_id)
+    }
+}