New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler incorrectly reports function return type declaration as source of inner type mismatch with conservative_impl_trait #46644

Open
mqudsi opened this Issue Dec 10, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@mqudsi
Copy link

mqudsi commented Dec 10, 2017

Given a function specified as returning a composite type that incorrectly returns an object with an inner type mismatch, the compiler reports the error as being in the function return type declaration rather than at the point the incorrect item is returned.

A sample git repo can be found here: https://git.neosmart.net/mqudsi/futuretest/src/rust-46644

The code in question:

fn create_future() -> impl Future<Item=(), Error=()> {
    return future::ok(Ok(()));
}

The compiler returns the following;

   Compiling futuretest v0.1.0 (file:///mnt/d/GIT/futuretest)
error[E0271]: type mismatch resolving `<futures::FutureResult<std::result::Result<(), _>, ()> as futures::Future>::Item == ()`
  --> src/main.rs:17:23
   |
17 | fn create_future() -> impl Future<Item=(), Error=()> {
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found ()
   |
   = note: expected type `std::result::Result<(), _>`
              found type `()`
   = note: the return type of a function must have a statically known size

error: aborting due to previous error

error: Could not compile `futuretest`.

To learn more, run the command again with --verbose.

@mqudsi mqudsi changed the title Compiler incorrectly reports function declaration as source of inner type mismatch with conservative_impl_trait Compiler incorrectly reports function return type declaration as source of inner type mismatch with conservative_impl_trait Dec 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment