Skip to content
New issue

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

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

Already on GitHub? # to your account

Confusing error message #36797

Closed
jthornber opened this issue Sep 28, 2016 · 1 comment
Closed

Confusing error message #36797

jthornber opened this issue Sep 28, 2016 · 1 comment

Comments

@jthornber
Copy link

A spurious semicolon meant this function was returning () rather than some form of io::Result. I feel the error message could have been more helpful, since the type was just plain wrong, rather than inadequately specified.

use std::fs::File;
use std::io;
use std::os::unix::io::AsRawFd;
use std::path::Path;

pub struct DMIoctl {
// FIXME: automate closing the fd
control_file: File

}

static IOCTL_CONTROL_PATH: &'static Path = Path::new("/dev/mapper/control");

impl DMIoctl {
fn new_specifying_control<P: AsRef>(path: &P) -> io::Result {
let i = DMIoctl { control_file: try!(File::open(path)) };

   // main.rs:21:9: 71:11 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required\

[E0282]
//main.rs:21 Ok(i);
^~

   Ok(i);

}

fn new() -> io::Result {
Self::new_specifying_control(IOCTL_CONTROL_PATH);
}
}

@TimNN
Copy link
Contributor

TimNN commented Sep 28, 2016

Duplicate of #24889.

Also, @jthornber you can get better code formatting by surrounding your code like this:

```rust
// your code goes here
```

That example would then render as

// your code goes here

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants