Browse Source

Illustrating rust-lang/rust#46711

rust-46711
Mahmoud Al-Qudsi 1 year ago
parent
commit
943d5ac763
2 changed files with 17 additions and 26 deletions
  1. 9
    17
      cargo.out
  2. 8
    9
      src/main.rs

+ 9
- 17
cargo.out View File

@@ -1,24 +1,16 @@
1 1
    Compiling futuretest v0.1.0 (file:///mnt/c/Users/Mahmoud/git/futuretest)
2
-error[E0271]: type mismatch resolving `<futures::FutureResult<(), std::string::String> as futures::IntoFuture>::Error == &str`
3
-  --> src/main.rs:13:10
2
+error[E0277]: the trait bound `(): futures::Future` is not satisfied
3
+  --> src/main.rs:17:1
4 4
    |
5
-13 |         .and_then(|_|
6
-   |          ^^^^^^^^ expected struct `std::string::String`, found &str
5
+17 | / fn test() -> MapErr<(), ()> {
6
+18 | |     future::ok(())
7
+19 | |         .map_err(|String| ())
8
+20 | | }
9
+   | |_^ the trait `futures::Future` is not implemented for `()`
7 10
    |
8
-   = note: expected type `std::string::String`
9
-              found type `&str`
11
+   = note: required by `futures::MapErr`
10 12
 
11
-error[E0271]: type mismatch resolving `<futures::FutureResult<(), std::string::String> as futures::IntoFuture>::Error == &str`
12
-  --> src/main.rs:20:10
13
-   |
14
-20 |     core.run(f).unwrap();
15
-   |          ^^^ expected struct `std::string::String`, found &str
16
-   |
17
-   = note: expected type `std::string::String`
18
-              found type `&str`
19
-   = note: required because of the requirements on the impl of `futures::Future` for `futures::AndThen<futures::Map<futures::MapErr<futures::FutureResult<(), ()>, [closure@src/main.rs:11:18: 11:43]>, [closure@src/main.rs:12:14: 12:67]>, futures::FutureResult<(), std::string::String>, [closure@src/main.rs:13:19: 16:14]>`
20
-
21
-error: aborting due to 2 previous errors
13
+error: aborting due to previous error
22 14
 
23 15
 error: Could not compile `futuretest`.
24 16
 

+ 8
- 9
src/main.rs View File

@@ -1,3 +1,5 @@
1
+#![feature(conservative_impl_trait)]
2
+
1 3
 extern crate futures;
2 4
 extern crate tokio_core;
3 5
 use futures::future::{self};
@@ -7,15 +9,12 @@ use tokio_core::reactor::Core;
7 9
 fn main() {
8 10
     let mut core = Core::new().expect("Failed to initialize tokio_core reactor!");
9 11
 
10
-    let f = future::result(Ok(()))
11
-        .map_err(|()| "&'static str error")
12
-        .map(|_| future::result(Err("another &'static str error")))
13
-        .and_then(|_|
14
-             future::result(Ok(())
15
-                .map_err(|()| "String error".to_owned())
16
-            )
17
-        )
18
-    ;
12
+    let f = test();
19 13
 
20 14
     core.run(f).unwrap();
21 15
 }
16
+
17
+fn test() -> MapErr<(), ()> {
18
+    future::ok(())
19
+        .map_err(|String| ())
20
+}

Loading…
Cancel
Save