Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Error message for #[async] on a for #65

Open
rubdos opened this issue Mar 2, 2018 · 1 comment
Open

Error message for #[async] on a for #65

rubdos opened this issue Mar 2, 2018 · 1 comment

Comments

@rubdos
Copy link

rubdos commented Mar 2, 2018

Consider

let (tx, rx) = mpsc::channel(1);
let process_bootstrap = async_block! {
    let msg = create_msg();
    #[async]
    for foo in rx {
        let msg = msg.clone();
        sink = await!(sink.send((msg, foo)))?;
    }
   Ok(())
};

Where the sink has io::Error as Error type, and rx obviously has () as Error type. This gives the very unhelpful message:

error[E0277]: the trait bound `std::io::Error: std::convert::From<()>` is not satisfied
   --> src/net/server.rs:142:33
    |
142 |           let process_bootstrap = async_block! {
    |  _________________________________^
143 | |             let msg = create_msg()
144 | |             #[async]
145 | |             for foo in rx {
...   |
150 | |             Ok(())
151 | |         };
    | |_________^ the trait `std::convert::From<()>` is not implemented for `std::io::Error`
    |

where the arrows point just around the block. Is it somehow possible to let the error actually point to the #[async] for loop?

@rubdos
Copy link
Author

rubdos commented Mar 2, 2018

Secondly, note that

#[async]
for foo in rx.map_err(|_| -> io::Error { unreachable!() }) {
}

works perfectly, but is quite painful to write. But that's not the real issue here, I guess :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant